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: Update the configuration of an application |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
package App::Cme::Command::update ; |
13
|
|
|
|
|
|
|
$App::Cme::Command::update::VERSION = '1.037'; |
14
|
1
|
|
|
1
|
|
672
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
15
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
16
|
1
|
|
|
1
|
|
10
|
use 5.10.1; |
|
1
|
|
|
|
|
3
|
|
17
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
6
|
use App::Cme -command ; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
16
|
|
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
1
|
|
303
|
use base qw/App::Cme::Common/; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
93
|
|
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
1
|
|
7
|
use Config::Model::ObjTreeScanner; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
21
|
|
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
1
|
|
4
|
use Config::Model; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
361
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub validate_args { |
27
|
0
|
|
|
0
|
1
|
|
my ($self, $opt, $args) = @_; |
28
|
0
|
|
|
|
|
|
$self->check_unknown_args($args); |
29
|
0
|
|
|
|
|
|
$self->process_args($opt,$args); |
30
|
0
|
|
|
|
|
|
return; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub opt_spec { |
34
|
0
|
|
|
0
|
1
|
|
my ( $class, $app ) = @_; |
35
|
|
|
|
|
|
|
return ( |
36
|
0
|
|
|
|
|
|
[ "edit!" => "Run editor after update is done" ], |
37
|
|
|
|
|
|
|
[ "backup:s" => "Create a backup of configuration files before saving." ], |
38
|
|
|
|
|
|
|
$class->cme_global_options, |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub usage_desc { |
43
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
44
|
0
|
|
|
|
|
|
my $desc = $self->SUPER::usage_desc; # "%c COMMAND %o" |
45
|
0
|
|
|
|
|
|
return "$desc [application] [file ]"; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub description { |
49
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
50
|
0
|
|
|
|
|
|
return $self->get_documentation; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub execute { |
54
|
0
|
|
|
0
|
1
|
|
my ($self, $opt, $args) = @_; |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
my ( $inst) = $self->instance($opt,$args); |
57
|
|
|
|
|
|
|
|
58
|
0
|
0
|
|
|
|
|
say "Updating data..." unless $opt->{quiet}; |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
my @msgs = $inst->update(quiet => $opt->{quiet}); |
61
|
|
|
|
|
|
|
|
62
|
0
|
0
|
0
|
|
|
|
if (@msgs and not $opt->{quiet}) { |
|
|
0
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
say "Update done"; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
elsif (not $opt->{quiet}) { |
66
|
|
|
|
|
|
|
say "Command done, but ".$opt->{_application} |
67
|
0
|
|
|
|
|
|
. " model has no provision for update"; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
0
|
0
|
|
|
|
|
if ($opt->{edit}) { |
71
|
0
|
|
|
|
|
|
say join("\n", grep {defined $_} @msgs ); |
|
0
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
$self->run_tk_ui ( $inst, $opt); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
else { |
75
|
0
|
|
|
|
|
|
$self->save($inst,$opt) ; |
76
|
0
|
|
|
|
|
|
say join("\n", grep {defined $_} @msgs ); |
|
0
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
return; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
__END__ |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=pod |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=encoding UTF-8 |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 NAME |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
App::Cme::Command::update - Update the configuration of an application |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 VERSION |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
version 1.037 |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 SYNOPSIS |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
cme update <application> |
101
|
|
|
|
|
|
|
# example: cme update dpkg-copyright |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 DESCRIPTION |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Update a configuration file. The update is done scanning external |
106
|
|
|
|
|
|
|
resource. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
For instance, C<cme update dpkg-copyright> command can be used to |
109
|
|
|
|
|
|
|
update a specific Debian package file (C<debian/copyright>). This is |
110
|
|
|
|
|
|
|
done by scanning the headers of source files. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Currently, only dpkg-copyright application currently supports updates. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
The configuration data (i.e. the content of C<debian/copyright> in |
115
|
|
|
|
|
|
|
this example) is mapped to a tree structure inside L<cme>. You can: |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=over 4 |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=item * |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
view this structure in YAML format by running C<cme dump dpkg-copyright> |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=item * |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
view this structure in Config::Model's format (aka C<cml>) by running |
126
|
|
|
|
|
|
|
C<cme dump -format cml dpkg-copyright>. This format is documented in |
127
|
|
|
|
|
|
|
L<Config::Model::Loader>. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=item * |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
get a graphical view with C<cme edit dpkg-copyright>. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=back |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 Common options |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
See L<cme/"Global Options">. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head1 options |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=over |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=item -open-item |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Open a specific item of the configuration when opening the editor |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=back |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 SEE ALSO |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
L<cme> |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head1 AUTHOR |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
Dominique Dumont |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
This software is Copyright (c) 2014-2022 by Dominique Dumont <ddumont@cpan.org>. |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
This is free software, licensed under: |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
The GNU Lesser General Public License, Version 2.1, February 1999 |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=cut |