| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# |
|
2
|
|
|
|
|
|
|
# This file is part of App-Cme |
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
# This software is Copyright (c) 2014-2022 by Dominique Dumont <ddumont@cpan.org>. |
|
5
|
|
|
|
|
|
|
# |
|
6
|
|
|
|
|
|
|
# This is free software, licensed under: |
|
7
|
|
|
|
|
|
|
# |
|
8
|
|
|
|
|
|
|
# The GNU Lesser General Public License, Version 2.1, February 1999 |
|
9
|
|
|
|
|
|
|
# |
|
10
|
|
|
|
|
|
|
# ABSTRACT: Search the configuration of an application |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
package App::Cme::Command::search ; |
|
13
|
|
|
|
|
|
|
$App::Cme::Command::search::VERSION = '1.037'; |
|
14
|
1
|
|
|
1
|
|
891
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
30
|
|
|
15
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
29
|
|
|
16
|
1
|
|
|
1
|
|
12
|
use 5.10.1; |
|
|
1
|
|
|
|
|
3
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
7
|
use App::Cme -command ; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
9
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
1
|
|
|
1
|
|
369
|
use base qw/App::Cme::Common/; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
115
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
1
|
|
|
1
|
|
6
|
use Config::Model::ObjTreeScanner; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
481
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub validate_args { |
|
25
|
1
|
|
|
1
|
1
|
2817
|
my ($self, $opt, $args) = @_; |
|
26
|
1
|
|
|
|
|
8
|
$self->check_unknown_args($args); |
|
27
|
1
|
|
|
|
|
6
|
$self->process_args($opt,$args); |
|
28
|
1
|
|
|
|
|
2
|
return; |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub opt_spec { |
|
32
|
1
|
|
|
1
|
1
|
3
|
my ( $class, $app ) = @_; |
|
33
|
|
|
|
|
|
|
return ( |
|
34
|
|
|
|
|
|
|
[ |
|
35
|
1
|
|
|
|
|
19
|
"search=s" => "string or pattern to search in configuration" , |
|
36
|
|
|
|
|
|
|
{ required => 1 } |
|
37
|
|
|
|
|
|
|
], |
|
38
|
|
|
|
|
|
|
[ |
|
39
|
|
|
|
|
|
|
"narrow-search=s" => "narrows down the search to element, value, key, summary, description or help", |
|
40
|
|
|
|
|
|
|
{ regex => qr/^(?:element|value|key|summary|description|help|all)$/, default => 'all' } |
|
41
|
|
|
|
|
|
|
], |
|
42
|
|
|
|
|
|
|
$class->cme_global_options, |
|
43
|
|
|
|
|
|
|
); |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub usage_desc { |
|
47
|
1
|
|
|
1
|
1
|
2000
|
my ($self) = @_; |
|
48
|
1
|
|
|
|
|
6
|
my $desc = $self->SUPER::usage_desc; # "%c COMMAND %o" |
|
49
|
1
|
|
|
|
|
19
|
return "$desc [application] [ config_file ] -search xxx [ -narrow-search ... ] " ; |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub description { |
|
53
|
0
|
|
|
0
|
1
|
0
|
my ($self) = @_; |
|
54
|
0
|
|
|
|
|
0
|
return $self->get_documentation; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub execute { |
|
58
|
1
|
|
|
1
|
1
|
8
|
my ($self, $opt, $args) = @_; |
|
59
|
|
|
|
|
|
|
|
|
60
|
1
|
|
|
|
|
15
|
my ($model, $inst, $root) = $self->init_cme($opt,$args); |
|
61
|
|
|
|
|
|
|
|
|
62
|
1
|
|
|
|
|
5952
|
my @res = $root->tree_searcher( type => $opt->{narrow_search} )->search($opt->{search}); |
|
63
|
1
|
|
|
|
|
10860
|
foreach my $path (@res) { |
|
64
|
2
|
|
|
|
|
22
|
print "$path"; |
|
65
|
2
|
|
|
|
|
40
|
my $obj = $root->grab($path); |
|
66
|
2
|
50
|
|
|
|
779
|
if ( $obj->get_type =~ /leaf|check_list/ ) { |
|
67
|
2
|
|
|
|
|
33
|
my $v = $obj->fetch; |
|
68
|
2
|
50
|
|
|
|
416
|
$v = defined $v ? $v : '<undef>'; |
|
69
|
2
|
|
|
|
|
11
|
print " -> '$v'"; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
2
|
|
|
|
|
27
|
print "\n"; |
|
72
|
|
|
|
|
|
|
} |
|
73
|
1
|
|
|
|
|
92
|
return; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
__END__ |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=pod |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=encoding UTF-8 |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 NAME |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
App::Cme::Command::search - Search the configuration of an application |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 VERSION |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
version 1.037 |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Search configuration data with the following options: |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=over |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=item -search |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Specifies a string or pattern to search. C<cme> will a list of path pointing |
|
103
|
|
|
|
|
|
|
to the matching tree element and their value. |
|
104
|
|
|
|
|
|
|
See L<Config::Model::AnyThing/grab(...)> for details |
|
105
|
|
|
|
|
|
|
on the path syntax. |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=item -narrow-search |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Narrows down the search to: |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=over |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=item element |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=item value |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=item key |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=item summary |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Summary text |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=item description |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
description text |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=item help |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
value help text |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=back |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=back |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Example: |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
$ cme search multistrap my_mstrap.conf -search http -narrow value |
|
138
|
|
|
|
|
|
|
sections:base source -> 'http://ftp.fr.debian.org' |
|
139
|
|
|
|
|
|
|
sections:debian source -> 'http://ftp.uk.debian.org/debian' |
|
140
|
|
|
|
|
|
|
sections:toolchains source -> 'http://www.emdebian.org/debian' |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head1 Common options |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
See L<cme/"Global Options">. |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
L<cme> |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 AUTHOR |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Dominique Dumont |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
This software is Copyright (c) 2014-2022 by Dominique Dumont <ddumont@cpan.org>. |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
This is free software, licensed under: |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
The GNU Lesser General Public License, Version 2.1, February 1999 |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=cut |