line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# -*- coding: utf-8 -*- |
2
|
|
|
|
|
|
|
# Copyright (C) 2011-2014 Rocky Bernstein <rocky@cpan.org> |
3
|
12
|
|
|
12
|
|
18720
|
use warnings; no warnings 'redefine'; use utf8; |
|
12
|
|
|
12
|
|
33
|
|
|
12
|
|
|
12
|
|
488
|
|
|
12
|
|
|
2
|
|
65
|
|
|
12
|
|
|
2
|
|
32
|
|
|
12
|
|
|
2
|
|
401
|
|
|
12
|
|
|
|
|
581
|
|
|
12
|
|
|
|
|
38
|
|
|
12
|
|
|
|
|
126
|
|
|
2
|
|
|
|
|
14
|
|
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
59
|
|
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
53
|
|
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
19
|
|
4
|
|
|
|
|
|
|
|
5
|
12
|
|
|
12
|
|
341
|
use rlib '../../../..'; |
|
12
|
|
|
2
|
|
29
|
|
|
12
|
|
|
|
|
83
|
|
|
2
|
|
|
|
|
69
|
|
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
10
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package Devel::Trepan::CmdProcessor::Command::Complete; |
8
|
|
|
|
|
|
|
|
9
|
12
|
|
|
12
|
|
4941
|
use Getopt::Long qw(GetOptionsFromArray); |
|
12
|
|
|
2
|
|
10522
|
|
|
12
|
|
|
|
|
174
|
|
|
2
|
|
|
|
|
650
|
|
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
21
|
|
10
|
|
|
|
|
|
|
use Devel::Trepan::Complete |
11
|
12
|
|
|
12
|
|
2458
|
qw(complete_packages complete_subs complete_builtins); |
|
12
|
|
|
2
|
|
103
|
|
|
12
|
|
|
|
|
1211
|
|
|
2
|
|
|
|
|
268
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
117
|
|
12
|
|
|
|
|
|
|
|
13
|
12
|
|
|
12
|
|
647
|
use if !@ISA, Devel::Trepan::CmdProcessor::Command ; |
|
12
|
|
|
2
|
|
34
|
|
|
12
|
|
|
|
|
85
|
|
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
14
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
unless (@ISA) { |
16
|
12
|
|
|
12
|
|
87
|
eval <<'EOE'; |
|
12
|
|
|
12
|
|
33
|
|
|
12
|
|
|
12
|
|
741
|
|
|
12
|
|
|
12
|
|
76
|
|
|
12
|
|
|
|
|
37
|
|
|
12
|
|
|
|
|
566
|
|
|
12
|
|
|
|
|
71
|
|
|
12
|
|
|
|
|
33
|
|
|
12
|
|
|
|
|
543
|
|
|
12
|
|
|
|
|
75
|
|
|
12
|
|
|
|
|
31
|
|
|
12
|
|
|
|
|
496
|
|
17
|
|
|
|
|
|
|
use constant CATEGORY => 'support'; |
18
|
|
|
|
|
|
|
use constant SHORT_HELP => 'List the completions for the rest of the line as a command'; |
19
|
|
|
|
|
|
|
use constant MAX_ARGS => undef; # Need at most this many - |
20
|
|
|
|
|
|
|
# undef -> unlimited |
21
|
|
|
|
|
|
|
use constant NEED_STACK => 0; |
22
|
|
|
|
|
|
|
EOE |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
12
|
|
|
12
|
|
2050
|
use strict; |
|
12
|
|
|
2
|
|
34
|
|
|
12
|
|
|
|
|
302
|
|
|
2
|
|
|
|
|
104
|
|
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
36
|
|
26
|
12
|
|
|
12
|
|
66
|
use vars qw(@ISA); |
|
12
|
|
|
2
|
|
30
|
|
|
12
|
|
|
|
|
684
|
|
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
96
|
|
27
|
|
|
|
|
|
|
@ISA = @CMD_ISA; |
28
|
12
|
|
|
12
|
|
75
|
use vars @CMD_VARS; # Value inherited from parent |
|
12
|
|
|
2
|
|
30
|
|
|
12
|
|
|
|
|
9499
|
|
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1432
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
our $NAME = set_name(); |
31
|
|
|
|
|
|
|
our $HELP = <<"HELP"; |
32
|
|
|
|
|
|
|
=pod |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
B<complete> [I<options>] I<prefix> |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
options: |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
-b | --builtins |
39
|
|
|
|
|
|
|
-f | --files |
40
|
|
|
|
|
|
|
-p | --packages |
41
|
|
|
|
|
|
|
-s | --subs |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
List the command completions of I<prefix>. |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head2 Examples: |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
complete se # => set server |
49
|
|
|
|
|
|
|
complete -p Tie::H # => Tie::Hash (probably) |
50
|
|
|
|
|
|
|
complete -s Tie::Hash::n |
51
|
|
|
|
|
|
|
# => Tie::Hash::new |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=cut |
54
|
|
|
|
|
|
|
HELP |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
my $DEFAULT_OPTIONS = { |
57
|
|
|
|
|
|
|
lexicals => 0, |
58
|
|
|
|
|
|
|
files => 0, |
59
|
|
|
|
|
|
|
'my' => 0, |
60
|
|
|
|
|
|
|
'our' => 0, |
61
|
|
|
|
|
|
|
packages => 0, |
62
|
|
|
|
|
|
|
subs => 0, |
63
|
|
|
|
|
|
|
}; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub parse_options($$) |
66
|
|
|
|
|
|
|
{ |
67
|
7
|
|
|
7
|
0
|
13
|
my ($self, $args) = @_; |
|
0
|
|
|
0
|
0
|
0
|
|
68
|
7
|
|
|
|
|
35
|
my %opts = %$DEFAULT_OPTIONS; |
|
0
|
|
|
|
|
0
|
|
69
|
|
|
|
|
|
|
my $result = &GetOptionsFromArray |
70
|
|
|
|
|
|
|
($args, |
71
|
|
|
|
|
|
|
'-b' => \$opts{builtins}, |
72
|
|
|
|
|
|
|
'--builtins' => \$opts{builtins}, |
73
|
|
|
|
|
|
|
'-f' => \$opts{files}, |
74
|
|
|
|
|
|
|
'--files' => \$opts{files}, |
75
|
|
|
|
|
|
|
'-p' => \$opts{packages}, |
76
|
|
|
|
|
|
|
'--packages' => \$opts{packages}, |
77
|
|
|
|
|
|
|
'-s' => \$opts{subs}, |
78
|
|
|
|
|
|
|
'--subs' => \$opts{subs} |
79
|
7
|
|
|
|
|
37
|
); |
|
0
|
|
|
|
|
0
|
|
80
|
|
|
|
|
|
|
|
81
|
7
|
|
|
|
|
3253
|
\%opts; |
|
0
|
|
|
|
|
0
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
# This method runs the command |
86
|
|
|
|
|
|
|
sub run($$) { |
87
|
0
|
|
|
0
|
0
|
0
|
my ($self, $args) = @_; |
|
7
|
|
|
7
|
0
|
16
|
|
88
|
0
|
|
|
|
|
0
|
my @args = @{$args}; shift @args; # remove "complete". |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
15
|
|
89
|
0
|
|
|
|
|
0
|
my $opts = parse_options($self, \@args); |
|
7
|
|
|
|
|
20
|
|
90
|
|
|
|
|
|
|
|
91
|
0
|
|
|
|
|
0
|
my $proc = $self->{proc}; |
|
7
|
|
|
|
|
17
|
|
92
|
|
|
|
|
|
|
|
93
|
0
|
0
|
0
|
|
|
0
|
if ($opts->{files}) { |
|
7
|
0
|
0
|
|
|
55
|
|
|
|
50
|
33
|
|
|
|
|
|
|
50
|
33
|
|
|
|
|
94
|
0
|
0
|
|
|
|
0
|
if (scalar @args != 1) { |
|
0
|
0
|
|
|
|
0
|
|
95
|
0
|
|
|
|
|
0
|
$proc->errmsg('Expecting only a single argument after options'); |
|
0
|
|
|
|
|
0
|
|
96
|
0
|
|
|
|
|
0
|
return; |
|
0
|
|
|
|
|
0
|
|
97
|
|
|
|
|
|
|
} |
98
|
0
|
|
|
|
|
0
|
foreach my $file ($proc->filename_complete($args[0])) { |
|
0
|
|
|
|
|
0
|
|
99
|
0
|
|
|
|
|
0
|
$proc->msg($file); |
|
0
|
|
|
|
|
0
|
|
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
} elsif ($opts->{builtins}||$opts->{packages}||$opts->{subs}) { |
102
|
0
|
0
|
|
|
|
0
|
if (scalar @args != 1) { |
|
0
|
0
|
|
|
|
0
|
|
103
|
0
|
|
|
|
|
0
|
$proc->errmsg('Expecting only a single argument after options'); |
|
0
|
|
|
|
|
0
|
|
104
|
0
|
|
|
|
|
0
|
return; |
|
0
|
|
|
|
|
0
|
|
105
|
|
|
|
|
|
|
} |
106
|
0
|
|
|
|
|
0
|
my $prefix = $args[0]; |
|
0
|
|
|
|
|
0
|
|
107
|
0
|
|
|
|
|
0
|
my @matches = (); |
|
0
|
|
|
|
|
0
|
|
108
|
0
|
0
|
|
|
|
0
|
push @matches, complete_builtins($prefix) if ($opts->{builtins}); |
|
0
|
0
|
|
|
|
0
|
|
109
|
0
|
0
|
|
|
|
0
|
push @matches, complete_packages($prefix) if ($opts->{packages}); |
|
0
|
0
|
|
|
|
0
|
|
110
|
0
|
0
|
|
|
|
0
|
push @matches, complete_subs($prefix) if ($opts->{subs}); |
|
0
|
0
|
|
|
|
0
|
|
111
|
0
|
|
|
|
|
0
|
for my $match (@matches) { |
|
0
|
|
|
|
|
0
|
|
112
|
0
|
|
|
|
|
0
|
$proc->msg($match); |
|
0
|
|
|
|
|
0
|
|
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
} else { |
115
|
0
|
|
|
|
|
0
|
my $cmd_argstr = $proc->{cmd_argstr}; |
|
7
|
|
|
|
|
13
|
|
116
|
0
|
0
|
|
|
|
0
|
my $last_arg = (' ' eq substr($cmd_argstr, -1)) ? '' : $args[-1]; |
|
7
|
100
|
|
|
|
21
|
|
117
|
0
|
0
|
|
|
|
0
|
$last_arg = '' unless defined $last_arg; |
|
7
|
50
|
|
|
|
21
|
|
118
|
0
|
|
|
|
|
0
|
for my $match ($proc->complete($cmd_argstr, $cmd_argstr, |
|
7
|
|
|
|
|
32
|
|
119
|
|
|
|
|
|
|
0, length($cmd_argstr))) { |
120
|
0
|
|
|
|
|
0
|
$proc->msg($match); |
|
23
|
|
|
|
|
105
|
|
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
unless (caller) { |
126
|
|
|
|
|
|
|
require Devel::Trepan::CmdProcessor; |
127
|
|
|
|
|
|
|
my $proc = Devel::Trepan::CmdProcessor->new; |
128
|
|
|
|
|
|
|
my $cmd = __PACKAGE__->new($proc); |
129
|
|
|
|
|
|
|
for my $prefix (qw(d b bt)) { |
130
|
|
|
|
|
|
|
$cmd->{proc}{cmd_argstr} = $prefix; |
131
|
|
|
|
|
|
|
$cmd->run([$cmd->name, $prefix]); |
132
|
|
|
|
|
|
|
print '=' x 40, "\n"; |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
for my $prefix ('set a') { |
135
|
|
|
|
|
|
|
$cmd->{proc}{cmd_argstr} = $prefix; |
136
|
|
|
|
|
|
|
$cmd->run([$cmd->name, $prefix]); |
137
|
|
|
|
|
|
|
print '=' x 40, "\n"; |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
for my $prefix ('help syntax c') { |
140
|
|
|
|
|
|
|
$cmd->{proc}{cmd_argstr} = $prefix; |
141
|
|
|
|
|
|
|
$cmd->run([$cmd->name, $prefix]); |
142
|
|
|
|
|
|
|
print '=' x 40, "\n"; |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
%DB::sub = (__PACKAGE__ . '::run', 1); |
146
|
|
|
|
|
|
|
for my $tuple (['-b', 'call'], ['-p', __PACKAGE__], |
147
|
|
|
|
|
|
|
['-s', __PACKAGE__ . '::r']) { |
148
|
|
|
|
|
|
|
my ($opt, $prefix) = @$tuple; |
149
|
|
|
|
|
|
|
$cmd->{proc}{cmd_argstr} = $prefix; |
150
|
|
|
|
|
|
|
$cmd->run([$cmd->name, $opt, $prefix]); |
151
|
|
|
|
|
|
|
print '=' x 40, "\n"; |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
# $cmd->run([$cmd->name, 'fdafsasfda']); |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
1; |