Przeglądaj źródła

Possibility to set all configuration options on command line

Morten Brix Pedersen 24 lat temu
rodzic
commit
15fe251ce6
1 zmienionych plików z 18 dodań i 6 usunięć
  1. 18 6
      pisg.pl

+ 18 - 6
pisg.pl

@@ -67,7 +67,7 @@ sub get_cmdline_options
     );
     );
 
 
     # Commandline options
     # Commandline options
-    my ($tmp, $help, $silent, $option);
+    my ($tmp, $help, $silent, $option, @cfg);
 
 
 my $usage = <<END_USAGE;
 my $usage = <<END_USAGE;
 Usage: pisg.pl [-ch channel] [-l logfile] [-o outputfile] [-ma maintainer]
 Usage: pisg.pl [-ch channel] [-l logfile] [-o outputfile] [-ma maintainer]
@@ -78,14 +78,15 @@ Usage: pisg.pl [-ch channel] [-l logfile] [-o outputfile] [-ma maintainer]
 -o  --outfile=xxx      : Name of HTML file to create
 -o  --outfile=xxx      : Name of HTML file to create
 -ma --maintainer=xxx   : Channel/statistics maintainer
 -ma --maintainer=xxx   : Channel/statistics maintainer
 -f  --format=xxx       : Logfile format [see FORMATS file]
 -f  --format=xxx       : Logfile format [see FORMATS file]
--n  --network=xxx      : IRC Network for the channel.
--d  --dir=xxx          : Analyze all files in this dir. Ignores logfile.
--p  --prefix=xxx       : Analyse only files prefixed by xxx in dir.
+-n  --network=xxx      : IRC network for the channel
+-d  --dir=xxx          : Analyze all files in this dir. Ignores logfile 
+-p  --prefix=xxx       : Analyse only files prefixed by xxx in dir
                          Only works with --dir
                          Only works with --dir
--mo --moduledir=xxx    : Directory containing pisg modules.
+-cf --cfg              : Specify configuration options, eg. -cf show_wpl=1
 -co --configfile=xxx   : Configuration file
 -co --configfile=xxx   : Configuration file
+-mo --moduledir=xxx    : Directory containing pisg modules
 -s  --silent           : Suppress output (except error messages)
 -s  --silent           : Suppress output (except error messages)
--h  --help             : Output this message and exit (-? also works).
+-h  --help             : Output this message and exit.
 
 
 Example:
 Example:
 
 
@@ -109,6 +110,7 @@ END_USAGE
                    'ignorefile=s' => \$tmp,
                    'ignorefile=s' => \$tmp,
                    'aliasfile=s'  => \$tmp,
                    'aliasfile=s'  => \$tmp,
                    'silent'       => \$silent,
                    'silent'       => \$silent,
+                   'cfg=s'        => \@cfg,
                    'help|?'       => \$help
                    'help|?'       => \$help
                ) == 0 or $help) {
                ) == 0 or $help) {
                    die($usage);
                    die($usage);
@@ -121,6 +123,16 @@ END_USAGE
 
 
     if ($silent) { $cfg{silent} = 1; }
     if ($silent) { $cfg{silent} = 1; }
 
 
+    if (@cfg) {
+        foreach (@cfg) {
+            if (/(.*)=(.*)/) {
+                $cfg{$1} = $2;
+            } else {
+                print STDERR "Warning: Couldn't parse -cfg option\n";
+            }
+        }
+    }
+
     return \%cfg;
     return \%cfg;
 
 
 }
 }