| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Gentoo::Probe::Cmd; |
|
2
|
|
|
|
|
|
|
our($VERSION)=q{1.0.6}; |
|
3
|
|
|
|
|
|
|
our(@ISA)=qw(Gentoo::Probe); |
|
4
|
8
|
|
|
8
|
|
4382
|
use strict;$|=1; |
|
|
8
|
|
|
|
|
16
|
|
|
|
8
|
|
|
|
|
469
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
30
|
|
|
30
|
|
1651
|
sub import { goto \&Exporter::import }; |
|
7
|
|
|
|
|
|
|
#use Text::Number; |
|
8
|
8
|
|
|
8
|
|
42
|
use Carp; |
|
|
8
|
|
|
|
|
15
|
|
|
|
8
|
|
|
|
|
541
|
|
|
9
|
8
|
|
|
8
|
|
43
|
use Gentoo::Probe; |
|
|
8
|
|
|
|
|
14
|
|
|
|
8
|
|
|
|
|
126
|
|
|
10
|
8
|
|
|
8
|
|
6572
|
use Getopt::WonderBra qw(); |
|
|
8
|
|
|
|
|
11063
|
|
|
|
8
|
|
|
|
|
7793
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub do_args(\%@); |
|
13
|
|
|
|
|
|
|
sub usage(@); |
|
14
|
|
|
|
|
|
|
############################################################################## |
|
15
|
|
|
|
|
|
|
# info for parsing and help. |
|
16
|
|
|
|
|
|
|
############################################################################## |
|
17
|
|
|
|
|
|
|
our(%act) = ( |
|
18
|
|
|
|
|
|
|
"u"=>["uninstalled", "include (only) uninstalled"], |
|
19
|
|
|
|
|
|
|
"i"=>["installed", "include (only) installed"], |
|
20
|
|
|
|
|
|
|
'l'=>["latest", "show only latest (implies -v)"], |
|
21
|
|
|
|
|
|
|
"c"=>["no_case", "ignore case"], |
|
22
|
|
|
|
|
|
|
"C"=>["case", "don't ignore case"], |
|
23
|
|
|
|
|
|
|
"d"=>["debug", "debug"], |
|
24
|
|
|
|
|
|
|
"v"=>["versions", "show versions"], |
|
25
|
|
|
|
|
|
|
"V"=>["verbose", "verbose output"], |
|
26
|
|
|
|
|
|
|
"b"=>["builds", "show ebuilds"], |
|
27
|
|
|
|
|
|
|
); |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
############################################################################## |
|
30
|
|
|
|
|
|
|
# constructor: arsed cmd linish args, and generates opts therefrom. |
|
31
|
|
|
|
|
|
|
############################################################################## |
|
32
|
|
|
|
|
|
|
sub new(@){ |
|
33
|
6
|
|
|
6
|
0
|
73
|
my $class = shift; |
|
34
|
6
|
50
|
|
|
|
32
|
my %opts = map { %{$_} } shift if ref $_[0]; |
|
|
6
|
|
|
|
|
7
|
|
|
|
6
|
|
|
|
|
52
|
|
|
35
|
6
|
50
|
|
|
|
27
|
do_args(%opts,@_) or usage(2,"do_args failed\n"); |
|
36
|
6
|
|
|
|
|
32
|
my $self = Gentoo::Probe::new($class,\%opts); |
|
37
|
0
|
|
|
|
|
0
|
$self->veto_args(\%opts); |
|
38
|
0
|
|
|
|
|
0
|
return $self; |
|
39
|
|
|
|
|
|
|
}; |
|
40
|
|
|
|
|
|
|
############################################################################# |
|
41
|
|
|
|
|
|
|
# display usage |
|
42
|
|
|
|
|
|
|
############################################################################# |
|
43
|
|
|
|
|
|
|
sub usage(@) { |
|
44
|
0
|
|
|
0
|
0
|
0
|
my $code = @_; |
|
45
|
0
|
0
|
|
|
|
0
|
select (STDERR) if $code; |
|
46
|
0
|
0
|
|
|
|
0
|
print STDERR @_, "\n\n" if @_; |
|
47
|
0
|
|
|
|
|
0
|
print split qr/^\s+/m, qq( |
|
48
|
|
|
|
|
|
|
usage: $0 [-opts] ... |
|
49
|
|
|
|
|
|
|
); |
|
50
|
0
|
|
|
|
|
0
|
for ( sort { uc($a) cmp uc($b) } keys %act ) { |
|
|
0
|
|
|
|
|
0
|
|
|
51
|
0
|
|
|
|
|
0
|
print " -", $_, " ", $act{$_}->[1], "\n"; |
|
52
|
|
|
|
|
|
|
}; |
|
53
|
0
|
|
|
|
|
0
|
exit $code; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
{ |
|
56
|
|
|
|
|
|
|
package main; |
|
57
|
0
|
|
|
0
|
|
0
|
sub help { goto &Gentoo::Probe::Cmd::usage; }; |
|
58
|
0
|
|
|
0
|
|
0
|
sub version { goto &Gentoo::Probe::Cmd::usage; }; |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
############################################################################# |
|
61
|
|
|
|
|
|
|
# parse up those args. |
|
62
|
|
|
|
|
|
|
############################################################################# |
|
63
|
|
|
|
|
|
|
sub do_args(\%@){ |
|
64
|
6
|
50
|
|
6
|
0
|
21
|
die "usage: do_args(\\\%opts,\\\@args)" |
|
65
|
|
|
|
|
|
|
unless @_; |
|
66
|
6
|
|
|
|
|
11
|
my $opts = shift; |
|
67
|
6
|
50
|
|
|
|
44
|
return 1 unless @_; |
|
68
|
0
|
|
|
|
|
|
local $_; |
|
69
|
0
|
|
|
|
|
|
for ( sort keys %act ) { |
|
70
|
0
|
|
|
|
|
|
$opts->{name($_,1)}=undef; |
|
71
|
|
|
|
|
|
|
}; |
|
72
|
0
|
|
|
|
|
|
@_=Getopt::WonderBra::getopt(join("",keys %act),@_); |
|
73
|
0
|
|
|
|
|
|
while(($_=shift @_) ne '--'){ |
|
74
|
0
|
0
|
|
|
|
|
die "no dash in '$_'" unless s/^-//; |
|
75
|
0
|
|
|
|
|
|
my ( $key, $val ) = do_arg(argdata($_),$_,@_); |
|
76
|
0
|
|
|
|
|
|
$opts->{$key}=$val; |
|
77
|
|
|
|
|
|
|
}; |
|
78
|
0
|
0
|
|
|
|
|
confess "expected '--'" unless $_ eq '--'; |
|
79
|
0
|
|
|
|
|
|
@{$opts->{pats}}=@_; |
|
|
0
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
return 1; |
|
81
|
|
|
|
|
|
|
}; |
|
82
|
|
|
|
|
|
|
sub do_arg($$\@){ |
|
83
|
0
|
|
|
0
|
0
|
|
our($argdata,$arg) = @_; |
|
84
|
0
|
0
|
|
|
|
|
die "internal error: $_ slipped past:\n" unless defined $argdata; |
|
85
|
0
|
0
|
|
|
|
|
die "arg is undef" unless defined $arg; |
|
86
|
0
|
0
|
|
|
|
|
if ( ref $argdata eq 'CODE' ) { |
|
87
|
0
|
|
|
|
|
|
$argdata->(); |
|
88
|
|
|
|
|
|
|
} else { |
|
89
|
0
|
|
|
|
|
|
local $_ = $argdata->[0]; |
|
90
|
0
|
0
|
|
|
|
|
die "internal error" unless defined($_); |
|
91
|
0
|
0
|
|
|
|
|
my $val = s/^no_// ? 0 : 1; |
|
92
|
0
|
|
|
|
|
|
return ( $_, $val ); |
|
93
|
|
|
|
|
|
|
}; |
|
94
|
|
|
|
|
|
|
}; |
|
95
|
|
|
|
|
|
|
sub argdata($){ |
|
96
|
0
|
0
|
|
0
|
0
|
|
confess "undef?" unless defined $act{$_[0]}; |
|
97
|
0
|
|
|
|
|
|
return $act{$_[0]}; |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
sub desc($){ |
|
100
|
0
|
|
|
0
|
0
|
|
return argdata($_[0])->[1]; |
|
101
|
|
|
|
|
|
|
}; |
|
102
|
|
|
|
|
|
|
sub name($;$){ |
|
103
|
0
|
|
|
0
|
0
|
|
my ($flag,$base) = @_; |
|
104
|
0
|
|
|
|
|
|
local $_ =argdata($flag)->[0]; |
|
105
|
0
|
0
|
|
|
|
|
s/^no_// if ( $base); |
|
106
|
0
|
|
|
|
|
|
return $_; |
|
107
|
|
|
|
|
|
|
} |
|
108
|
|
|
|
|
|
|
1; |