line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Astro::App::Satpass2::Macro::Command; |
2
|
|
|
|
|
|
|
|
3
|
20
|
|
|
20
|
|
1353
|
use 5.008; |
|
20
|
|
|
|
|
77
|
|
4
|
|
|
|
|
|
|
|
5
|
20
|
|
|
20
|
|
118
|
use strict; |
|
20
|
|
|
|
|
47
|
|
|
20
|
|
|
|
|
440
|
|
6
|
20
|
|
|
20
|
|
103
|
use warnings; |
|
20
|
|
|
|
|
48
|
|
|
20
|
|
|
|
|
639
|
|
7
|
|
|
|
|
|
|
|
8
|
20
|
|
|
20
|
|
110
|
use parent qw{ Astro::App::Satpass2::Macro }; |
|
20
|
|
|
|
|
63
|
|
|
20
|
|
|
|
|
136
|
|
9
|
|
|
|
|
|
|
|
10
|
20
|
|
|
20
|
|
1101
|
use Astro::App::Satpass2::Utils qw{ quoter ARRAY_REF @CARP_NOT }; |
|
20
|
|
|
|
|
43
|
|
|
20
|
|
|
|
|
11210
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.051'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub execute { |
15
|
19
|
|
|
19
|
1
|
43
|
my ( $self, $name ) = @_; |
16
|
19
|
50
|
|
|
|
59
|
$self->implements( $name ) |
17
|
|
|
|
|
|
|
or $self->weep( "'$name' not implemented by this object" ); |
18
|
19
|
|
|
|
|
54
|
my $satpass2 = $self->parent(); |
19
|
19
|
|
|
|
|
31
|
my $output; |
20
|
19
|
|
|
|
|
27
|
foreach my $cmd ( @{ $self->{def} } ) { |
|
19
|
|
|
|
|
43
|
|
21
|
|
|
|
|
|
|
eval { |
22
|
19
|
50
|
|
|
|
68
|
if ( defined( my $buffer = $satpass2->execute( $cmd ) ) ) { |
23
|
18
|
|
|
|
|
41
|
$output .= $buffer; |
24
|
|
|
|
|
|
|
} |
25
|
18
|
|
|
|
|
63
|
1; |
26
|
19
|
100
|
|
|
|
30
|
} or do { |
27
|
1
|
|
|
|
|
71
|
$satpass2->__wail( $@ ); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
} |
30
|
18
|
|
|
|
|
47
|
return $output; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub completion { |
34
|
9
|
|
|
9
|
1
|
22
|
my ( $self, $text ) = @_; |
35
|
|
|
|
|
|
|
$self->{completion} |
36
|
9
|
50
|
|
|
|
43
|
or return; |
37
|
0
|
0
|
|
|
|
0
|
defined $text |
38
|
|
|
|
|
|
|
or $text = ''; |
39
|
0
|
0
|
|
|
|
0
|
my @rslt = sort( grep { ! index $_, $text } @{ $self->{completion} } ) |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
40
|
|
|
|
|
|
|
or return; |
41
|
0
|
|
|
|
|
0
|
return \@rslt; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub def { |
45
|
9
|
|
|
9
|
1
|
18
|
my ( $self ) = @_; |
46
|
9
|
|
|
|
|
19
|
my @def = @{ $self->{def} }; |
|
9
|
|
|
|
|
25
|
|
47
|
9
|
50
|
|
|
|
33
|
return wantarray ? @def : \@def; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub init { |
51
|
16
|
|
|
16
|
1
|
279
|
my ( $self ) = @_; |
52
|
16
|
|
|
|
|
75
|
$self->SUPER::init(); |
53
|
|
|
|
|
|
|
ARRAY_REF eq ref $self->{def} |
54
|
16
|
50
|
|
|
|
216
|
or $self->wail( q{Attribute 'def' must be an array reference} ); |
55
|
16
|
|
|
|
|
52
|
$self->{implements} = { map { $_ => 1 } $self->name() }; |
|
16
|
|
|
|
|
114
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
$self->{completion} |
58
|
0
|
|
|
|
|
0
|
and @{ $self->{completion} } = map { split qr< \s+ >smx } |
|
0
|
|
|
|
|
0
|
|
59
|
16
|
50
|
|
|
|
60
|
@{ $self->{completion} }; |
|
0
|
|
|
|
|
0
|
|
60
|
|
|
|
|
|
|
|
61
|
16
|
|
|
|
|
37
|
return; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# Rewrite level1 macro definitions to level 2 commands. Note that this |
65
|
|
|
|
|
|
|
# is idempotent. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub __level1_rewrite { # TODO get rid of this when level1 support goes away |
68
|
8
|
|
|
8
|
|
15
|
my ( $self ) = @_; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
delete $self->{level1} |
71
|
|
|
|
|
|
|
and $self->{def} = $self->parent()->__rewrite_level1_macro_def( |
72
|
8
|
50
|
|
|
|
32
|
$self->name(), $self->{def} ); |
73
|
|
|
|
|
|
|
|
74
|
8
|
|
|
|
|
19
|
return; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
__END__ |