File Coverage

blib/lib/Wizard/Shell.pm
Criterion Covered Total %
statement 9 29 31.0
branch 0 10 0.0
condition 0 9 0.0
subroutine 3 8 37.5
pod 0 5 0.0
total 12 61 19.6


line stmt bran cond sub pod time code
1             # -*- perl -*-
2             #
3             #
4             # Wizard - A Perl package for implementing system administration
5             # applications in the style of Windows wizards.
6             #
7             #
8             # This module is
9             #
10             # Copyright (C) 1999 Jochen Wiedmann
11             # Am Eisteich 9
12             # 72555 Metzingen
13             # Germany
14             #
15             # Email: joe@ispsoft.de
16             # Phone: +49 7123 14887
17             #
18             # and Amarendran R. Subramanian
19             # Grundstr. 32
20             # 72810 Gomaringen
21             # Germany
22             #
23             # Email: amar@ispsoft.de
24             # Phone: +49 7072 920696
25             #
26             # All Rights Reserved.
27             #
28             # You may distribute under the terms of either the GNU General Public
29             # License or the Artistic License, as specified in the Perl README file.
30             #
31              
32 1     1   614 use strict;
  1         3  
  1         37  
33              
34 1     1   5 use Wizard ();
  1         1  
  1         15  
35 1     1   566 use Wizard::Form::Shell ();
  1         2  
  1         279  
36              
37              
38             =pod
39              
40             =head1 NAME
41              
42             Wizard::Shell - A subclass for running Wizard applications in a shell.
43              
44              
45             =head1 SYNOPSIS
46              
47             # Create a new shell wizard
48             use Wizard::Shell;
49             my $wiz = Wizard::Shell->new('form' => $form)
50              
51              
52             =head1 DESCRIPTION
53              
54             The Shell wizard is a subclass of Wizard, that will run in a shell. The
55             input elements are written to stdout and the application will query you
56             for input.
57              
58             =cut
59              
60             package Wizard::Shell;
61              
62             @Wizard::Shell::ISA = qw(Wizard);
63              
64              
65             sub new {
66 0     0 0   my $self = shift; my $attr = shift;
  0            
67 0   0       $attr->{'formClass'} ||= 'Wizard::Form::Shell';
68 0           $self->SUPER::new($attr);
69             }
70              
71              
72             sub State {
73 0     0 0   my $self = shift;
74 0 0         if (@_) {
75 0           $self->{'state'} = shift;
76             }
77 0           $self->{'state'};
78             }
79              
80             sub param {
81 0     0 0   my $self = shift;
82 0   0       my $params = $self->{'params'} || {};
83 0 0         return keys %$params unless (@_);
84 0           my $var = shift;
85 0   0       my $vars = $params->{$var} || [];
86 0 0         if (@_) {
87 0           my $val = shift;
88 0 0 0       $vars = (defined($val) and ref($val)) ? $val : [$val];
89 0           $self->{'params'}->{$var} = $vars;
90             }
91 0 0         wantarray ? @$vars : $vars->[0];
92             }
93              
94             # Store is a dummy method here, because we need no persistency
95 0     0 0   sub Store { }
96              
97 0     0 0   sub ResetParam { shift->{'params'} = {} }
98              
99              
100             1;
101              
102             __END__