Cme/Command/update.pm

filter: Statementstmt 47.8% 22 / 46 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 58.3% 7 / 12 Podpod 100% 5 / 5 totaltotal 44.7% 34 / 76 CC 6 SCAR 27.5
CC
6
Cov
39%
execute
42.0
validate_args
2.0
opt_spec
2.0
CRAP 15.7
« Cme/Common.pm ↑ Summary Cme/Command/fix.pm »
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 1 $App::Cme::Command::update::VERSION = '1.049';
14 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use 5.10.1;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 1 ▶use App::Cme -command ;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 1 ▶use base qw/App::Cme::Common/;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 1 ▶use Config::Model::ObjTreeScanner;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 1 ▶use Config::Model;
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 0 ▶sub validate_args {
Subroutine validate_args: not called CC=1 SCAR=6.9
Pod documented
27 0 my ($self, $opt, $args) = @_;
28 0 $self->check_unknown_args($args);
29 0 $self->process_args($opt,$args);
30 0 return;
31 }
32  
33 0 ▶sub opt_spec {
Subroutine opt_spec: not called CC=1 SCAR=6.9
Pod documented
34 0 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 0 ▶sub usage_desc {
Subroutine usage_desc: not called CC=1 SCAR=6.9
Pod documented
43 0 my ($self) = @_;
44 0 my $desc = $self->SUPER::usage_desc; # "%c COMMAND %o"
45 0 return "$desc [application] [file ]";
46 }
47  
48 0 ▶sub description {
Subroutine description: not called CC=1 SCAR=6.9
Pod documented
49 0 my ($self) = @_;
50 0 return $self->get_documentation;
51 }
52  
53 0 ▶sub execute {
Subroutine execute: not called CC=6 SCAR=37.4
Pod documented
54 0 my ($self, $opt, $args) = @_;
55  
56 0 my ( $inst) = $self->instance($opt,$args);
57  
58 0 ▶ say "Updating data..." unless $opt->{quiet};
Branch: 1 branch
BranchTrueFalseTotal
unless $opt->{"quiet"} 0 0 0
59  
60 0 my @msgs = $inst->update(quiet => $opt->{quiet});
61  
62 0 ▶ if (@msgs and not $opt->{quiet}) {
Branch: 2 branches
BranchTrueFalseTotal
if (@msgs and not $opt->{'quiet'}) { } 0 0 0
elsif (not $opt->{'quiet'}) { } 0 0 0
Condition0%0/3
@msgs and not $opt->{"quiet"}
!ll&&!rl&&r
000
MC/DC0%0/2
@msgs and not $opt->{"quiet"}
@msgs not $opt->{"quiet"}
Truth table0%0/3
A and not(B)
A= @msgsB= not $opt->{"quiet"}
ABresult
0X0
100
111
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 # remove undef values or empty strings. Literal '0' are not
71 # expected here
72 0 say join("\n", grep {$_} @msgs );
73  
74 0 ▶ if ($opt->{edit}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opt->{'edit'}) { } 0 0 0
75 0 $self->run_tk_ui ( $inst, $opt);
76 }
77 else {
78 0 $self->save($inst,$opt) ;
79 }
80  
81 0 return;
82 }
83  
84 1 1;
85  
86 __END__
« Cme/Common.pm ↑ Summary Cme/Command/fix.pm »