line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CLI::Base; |
2
|
1
|
|
|
1
|
|
3
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
37
|
|
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
3
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
25
|
|
5
|
1
|
|
|
1
|
|
3
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
47
|
|
6
|
1
|
|
|
|
|
60
|
use CLI qw(INTEGER FLOAT STRING SSTRING TIME DEGREE |
7
|
1
|
|
|
1
|
|
4
|
BOOLEAN typeStr); |
|
1
|
|
|
|
|
0
|
|
8
|
1
|
|
|
1
|
|
4
|
use Astro::Time qw(str2turn); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
390
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
0
|
|
|
0
|
0
|
0
|
my $proto = shift; |
12
|
0
|
|
0
|
|
|
0
|
my $class = ref($proto) || $proto; |
13
|
|
|
|
|
|
|
|
14
|
0
|
|
|
|
|
0
|
my $name = shift; |
15
|
0
|
|
|
|
|
0
|
my $value = shift; |
16
|
0
|
|
|
|
|
0
|
my $type = shift; |
17
|
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
0
|
my $self = { |
19
|
|
|
|
|
|
|
NAME => $name, |
20
|
|
|
|
|
|
|
TYPE => $type, |
21
|
|
|
|
|
|
|
VALUE => $value, |
22
|
|
|
|
|
|
|
FUNC => undef, |
23
|
|
|
|
|
|
|
MIN => undef, |
24
|
|
|
|
|
|
|
MAX => undef |
25
|
|
|
|
|
|
|
}; |
26
|
0
|
|
|
|
|
0
|
bless ($self, $class); |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
0
|
return $self; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub value { |
32
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
33
|
0
|
0
|
|
|
|
0
|
if (@_) {$self->{VALUE} = shift } |
|
0
|
|
|
|
|
0
|
|
34
|
0
|
|
|
|
|
0
|
return $self->{VALUE}; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub type { |
38
|
14
|
|
|
14
|
0
|
10
|
my $self = shift; |
39
|
14
|
50
|
|
|
|
22
|
if (@_) { $self->{TYPE} = shift } |
|
0
|
|
|
|
|
0
|
|
40
|
14
|
|
|
|
|
27
|
return $self->{TYPE}; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub name { |
44
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
45
|
0
|
0
|
|
|
|
0
|
if (@_) { $self->{NAME} = shift } |
|
0
|
|
|
|
|
0
|
|
46
|
0
|
|
|
|
|
0
|
return $self->{NAME}; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub function { |
50
|
13
|
|
|
13
|
0
|
9
|
my $self = shift; |
51
|
13
|
50
|
|
|
|
18
|
if (@_) { $self->{FUNC} = shift } |
|
0
|
|
|
|
|
0
|
|
52
|
13
|
|
|
|
|
37
|
return $self->{FUNC}; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub min { |
56
|
11
|
|
|
11
|
0
|
13
|
my $self = shift; |
57
|
11
|
100
|
|
|
|
15
|
if (@_) { |
58
|
2
|
|
|
|
|
10
|
my $type = $self->type(); |
59
|
2
|
0
|
66
|
|
|
23
|
if (!($type == INTEGER || $type == FLOAT || |
|
|
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
60
|
|
|
|
|
|
|
$type == TIME || $type == DEGREE)) { |
61
|
0
|
|
|
|
|
0
|
carp 'Cannot set minimum value for type ', typeStr($self->type()), "\n"; |
62
|
0
|
|
|
|
|
0
|
return undef; |
63
|
|
|
|
|
|
|
} |
64
|
2
|
|
|
|
|
4
|
$self->{MIN} = shift; |
65
|
|
|
|
|
|
|
} |
66
|
11
|
|
|
|
|
20
|
return $self->{MIN}; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub max { |
70
|
10
|
|
|
10
|
0
|
6
|
my $self = shift; |
71
|
10
|
100
|
|
|
|
17
|
if (@_) { |
72
|
1
|
|
|
|
|
11
|
my $type = $self->type(); |
73
|
1
|
0
|
33
|
|
|
4
|
if (!($type == INTEGER || $type == FLOAT || |
|
|
|
33
|
|
|
|
|
|
|
|
0
|
|
|
|
|
74
|
|
|
|
|
|
|
$type == TIME || $type == DEGREE)) { |
75
|
0
|
|
|
|
|
0
|
carp 'Cannot set maximum value for type ', $self->type(), "\n"; |
76
|
0
|
|
|
|
|
0
|
return undef; |
77
|
|
|
|
|
|
|
} |
78
|
1
|
|
|
|
|
2
|
$self->{MAX} = shift; |
79
|
|
|
|
|
|
|
} |
80
|
10
|
|
|
|
|
15
|
return $self->{MAX}; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub parse { |
84
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
85
|
0
|
|
|
|
|
|
my $string = shift; |
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
my $name = $self->{NAME}; |
88
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
carp "Could not parse \"$name $string\""; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; |
94
|
|
|
|
|
|
|
|