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: Check the configuration of an application |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
package App::Cme::Command::check ; |
13
|
|
|
|
|
|
|
$App::Cme::Command::check::VERSION = '1.037'; |
14
|
1
|
|
|
1
|
|
18514
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
34
|
|
15
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
31
|
|
16
|
1
|
|
|
1
|
|
14
|
use 5.10.1; |
|
1
|
|
|
|
|
6
|
|
17
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
5
|
use App::Cme -command ; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
12
|
|
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
1
|
|
347
|
use base qw/App::Cme::Common/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
539
|
|
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
1
|
|
6
|
use Config::Model::ObjTreeScanner; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
326
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub validate_args { |
25
|
2
|
|
|
2
|
1
|
5075
|
my ($self, $opt, $args) = @_; |
26
|
|
|
|
|
|
|
|
27
|
2
|
|
|
|
|
13
|
$self->check_unknown_args($args); |
28
|
2
|
|
|
|
|
23
|
$self->process_args($opt,$args); |
29
|
2
|
|
|
|
|
7
|
return; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub opt_spec { |
33
|
2
|
|
|
2
|
1
|
6
|
my ( $class, $app ) = @_; |
34
|
|
|
|
|
|
|
return ( |
35
|
2
|
|
|
|
|
21
|
[ "strict!" => "cme will exit 1 if warnings are found during check" ], |
36
|
|
|
|
|
|
|
$class->cme_global_options, |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub usage_desc { |
41
|
2
|
|
|
2
|
1
|
4003
|
my ($self) = @_; |
42
|
2
|
|
|
|
|
15
|
my $desc = $self->SUPER::usage_desc; # "%c COMMAND %o" |
43
|
2
|
|
|
|
|
42
|
return "$desc [application] [ config_file ]"; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub description { |
47
|
0
|
|
|
0
|
1
|
0
|
my ($self) = @_; |
48
|
0
|
|
|
|
|
0
|
return $self->get_documentation; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub execute { |
52
|
2
|
|
|
2
|
1
|
15
|
my ($self, $opt, $args) = @_; |
53
|
|
|
|
|
|
|
|
54
|
2
|
|
|
|
|
20
|
my ($model, $inst, $root) = $self->init_cme($opt,$args); |
55
|
2
|
50
|
|
|
|
11582
|
my $check = $opt->{force_load} ? 'no' : 'yes' ; |
56
|
2
|
100
|
|
|
|
82
|
say "Loading data..." if $opt->{verbose}; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Config::Model::ObjTreeScanner->new( |
59
|
|
|
|
18
|
|
|
leaf_cb => sub { }, |
60
|
2
|
|
|
|
|
57
|
check => $check, |
61
|
|
|
|
|
|
|
)->scan_node( undef, $root ); |
62
|
|
|
|
|
|
|
|
63
|
2
|
100
|
|
|
|
66
|
say "Checking data.." if $opt->{verbose}; |
64
|
2
|
|
|
|
|
32
|
$root->dump_tree( mode => 'full' ); # light check (value per value) |
65
|
2
|
|
|
|
|
8122
|
$root->deep_check; # consistency check |
66
|
2
|
100
|
|
|
|
2187
|
say "Check done." if $opt->{verbose}; |
67
|
|
|
|
|
|
|
|
68
|
2
|
|
|
|
|
32
|
my $ouch = $inst->has_warning; |
69
|
|
|
|
|
|
|
|
70
|
2
|
50
|
|
|
|
2154
|
if ( $ouch ) { |
71
|
0
|
|
|
|
|
0
|
my $app = $inst->application; |
72
|
0
|
|
|
|
|
0
|
warn "you can try 'cme fix $app' to fix the warnings shown above\n"; |
73
|
0
|
0
|
|
|
|
0
|
die "Found $ouch warnings in strict mode\n" if $opt->{strict}; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
2
|
|
|
|
|
109
|
return; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
__END__ |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=pod |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=encoding UTF-8 |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 NAME |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
App::Cme::Command::check - Check the configuration of an application |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 VERSION |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
version 1.037 |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 SYNOPSIS |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# standard usage |
98
|
|
|
|
|
|
|
cme check popcon |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
# read data from arbitrary file (with Config::Model::Dpkg) |
101
|
|
|
|
|
|
|
cme check dpkg-copyright path/to/file |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 DESCRIPTION |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Checks the content of the configuration file of an application. Prints warnings |
106
|
|
|
|
|
|
|
and errors on STDOUT. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Example: |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
cme check fstab |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Some applications allows one to override the default configuration file. |
113
|
|
|
|
|
|
|
For instance, with Debian copyright model, you can run cme on a different file: |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
cme check dpkg-copyright foobar |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
or directly check copyright data on STDIN: |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
curl http://metadata.ftp-master.debian.org/changelogs/main/f/frozen-bubble/unstable_copyright \ |
120
|
|
|
|
|
|
|
| cme check dpkg-copyright - |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 Common options |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
See L<cme/"Global Options">. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 options |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=over |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=item -strict |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
When set, cme exits 1 if warnings are found. By default, C<cme> exits |
133
|
|
|
|
|
|
|
0 when warnings are found. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=back |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 EXIT CODE |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
cme exits 0 when no errors are found. Exit 1 otherwise. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
If C<-strict> option is set, cme exits 1 when warnings are found. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 SEE ALSO |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
L<cme> |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head1 AUTHOR |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Dominique Dumont |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
This software is Copyright (c) 2014-2022 by Dominique Dumont <ddumont@cpan.org>. |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
This is free software, licensed under: |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
The GNU Lesser General Public License, Version 2.1, February 1999 |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=cut |