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