Cme/Command/fix.pm

filter: Statementstmt 41.0% 16 / 39 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 5 / 10 Podpod 100% 5 / 5 totaltotal 43.3% 26 / 60 CC 5 SCAR 24.5
CC
5
Cov
36%
execute
30.0
validate_args
2.0
opt_spec
2.0
CRAP 11.6
« Cme/Command/update.pm ↑ Summary Cme/Command/run.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: Fix the configuration of an application
11  
12 package App::Cme::Command::fix ;
13 1 $App::Cme::Command::fix::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 0 ▶sub validate_args {
Subroutine validate_args: not called CC=1 SCAR=6.9
Pod documented
23 0 my ($self, $opt, $args) = @_;
24 0 $self->check_unknown_args($args);
25 0 $self->process_args($opt,$args);
26 0 return;
27 }
28  
29 0 ▶sub opt_spec {
Subroutine opt_spec: not called CC=1 SCAR=6.9
Pod documented
30 0 my ( $class, $app ) = @_;
31 return (
32 0 [ "from=s@" => "fix only a subset of a configuration tree" ],
33 [ "backup:s" => "Create a backup of configuration files before saving." ],
34 [ "filter=s" => "pattern to select the element name to be fixed"],
35 $class->cme_global_options,
36 );
37 }
38  
39 0 ▶sub usage_desc {
Subroutine usage_desc: not called CC=1 SCAR=6.9
Pod documented
40 0 my ($self) = @_;
41 0 my $desc = $self->SUPER::usage_desc; # "%c COMMAND %o"
42 0 return "$desc [application] [ file ]";
43 }
44  
45 0 ▶sub description {
Subroutine description: not called CC=1 SCAR=6.9
Pod documented
46 0 my ($self) = @_;
47 0 return $self->get_documentation;
48 }
49  
50 0 ▶sub execute {
Subroutine execute: not called CC=5 SCAR=34.0
Pod documented
51 0 my ($self, $opt, $args) = @_;
52  
53 0 my ($model, $inst, $root) = $self->init_cme($opt,$args);
54  
55 0 ▶ my @fix_from = $opt->{from} ? @{$opt->{from}} : ('') ;
Branch: 1 branch
BranchTrueFalseTotal
$opt->{'from'} ? : 0 0 0
56  
57 0 foreach my $path (@fix_from) {
58 0 my $node_to_fix = $inst->config_root->grab($path);
59 0 my $msg = "cme: running fix on ".$inst->name." configuration";
60 0 ▶ $msg .= "from node ". $node_to_fix->name if $path;
Branch: 1 branch
BranchTrueFalseTotal
if $path 0 0 0
61 0 ▶ say $msg. "..." if $opt->{verbose};
Branch: 1 branch
BranchTrueFalseTotal
if $opt->{"verbose"} 0 0 0
62 0 $node_to_fix->apply_fixes($opt->{fix_filter});
63 }
64  
65 0 $self->save($inst,$opt) ;
66 0 return;
67 }
68  
69 1 1;
70  
71 __END__
« Cme/Command/update.pm ↑ Summary Cme/Command/run.pm »