pf-tools/pf-tools: help section and more readable error when mis...

parmelan-guest at users.alioth.debian.org parmelan-guest at users.alioth.debian.org
Mon Dec 8 17:08:48 UTC 2014


details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/76dad09b8e63
changeset: 1363:76dad09b8e63
user:      shad
date:      Mon Dec 08 18:08:39 2014 +0100
description:
help section and more readable error when mistyping on partial update-config

diffstat:

 lib/PFTools/Utils.pm |   7 ++++++-
 sbin/update-config   |  26 +++++++-------------------
 2 files changed, 13 insertions(+), 20 deletions(-)

diffs (67 lines):

diff -r dd013c5992b5 -r 76dad09b8e63 lib/PFTools/Utils.pm
--- a/lib/PFTools/Utils.pm	Mon Dec 08 14:54:16 2014 +0100
+++ b/lib/PFTools/Utils.pm	Mon Dec 08 18:08:39 2014 +0100
@@ -687,7 +687,10 @@
         croak q{ERROR: update feature is deactivated in config file};
     }
 
-    my $sections_to_update = @{$options->{section}} ? $options->{section} : $host_config->{'__sections_order'};
+    my $sections_to_update
+        = @{ $options->{section} }
+        ? $options->{section}
+        : $host_config->{'__sections_order'};
 
     my @sortedkeys = sort { sort_config_sections( $host_config, $a, $b ) }
         @{$sections_to_update};
@@ -812,6 +815,8 @@
     my $errorcount = 0;
 
     foreach my $section ( @{$sortedkeys} ) {
+        croak qq{ERROR: Undefined section '$section' in config files.}
+            if !defined $host_config->{$section};
         next if $host_config->{$section}->{'action'} eq 'actiongroup';
 
         if (    not defined $host_config->{$section}->{'doing'}
diff -r dd013c5992b5 -r 76dad09b8e63 sbin/update-config
--- a/sbin/update-config	Mon Dec 08 14:54:16 2014 +0100
+++ b/sbin/update-config	Mon Dec 08 18:08:39 2014 +0100
@@ -36,25 +36,11 @@
 my $program = basename $PROGRAM_NAME;
 
 my @options_specs = (
-    'config|c=s',
-    'branch=s',
-    'debug|d',
-    'diff|u',
-    'forcereload|f',
-    'forcecolor',
-    'help', 
-    'host|h=s',
-    'install|i',
-    'noaction',
-    'nocolor',
-    'noupdate',
-    'pkg_type|p=s',
-    'quiet|q',
-    'section=s',
-    'simul|s',
-    'site=s',
-    'store=s',
-    'verbose|v',
+    'config|c=s',    'branch=s',   'debug|d',   'diff|u',
+    'forcereload|f', 'forcecolor', 'help',      'host|h=s',
+    'install|i',     'noaction',   'nocolor',   'noupdate',
+    'pkg_type|p=s',  'quiet|q',    'section=s', 'simul|s',
+    'site=s',        'store=s',    'verbose|v',
 );
 
 my $options = {
@@ -143,6 +129,8 @@
 	--nocolor		: dont colorize the output
 	--noaction		: execute on_noaction directives
 	--noupdate		: execute on_noupdate directives
+	--section		: update only the selected sections and associated dependances
+				  Can be used several time and the parameter must be an existing section name
 
 END_OF_HELP
 



More information about the pf-tools-commits mailing list