X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Fperl%2FConfig.pm;h=552690caccea76fa85eeb8feb2a1dfff67125e4a;hb=d60ede19ab84382101d313e3185b1a0ef6714088;hp=8d98c5615aa92a8736430c4e21c4aea4bcd86d98;hpb=c5d261a52b2086c4acb843da7dbcf00746894347;p=libucw.git diff --git a/lib/perl/Config.pm b/lib/perl/Config.pm index 8d98c561..552690ca 100644 --- a/lib/perl/Config.pm +++ b/lib/perl/Config.pm @@ -5,7 +5,7 @@ # This software may be freely distributed and used according to the terms # of the GNU Lesser General Public License. -package Sherlock::Config; +package UCW::Config; use strict; use warnings; @@ -14,6 +14,9 @@ use Getopt::Long; our %Sections = (); our $DefaultConfigFile = ""; +our $Usage = "-C, --config filename Override the default configuration file +-S, --set sec.item=val Manual setting of a configuration item"; + sub Parse(@) { my @options = @_; @@ -28,12 +31,12 @@ sub Parse(@) { } foreach my $section (keys %Sections) { my $opts = $Sections{$section}; - my $optlist = join(" ", keys %$opts); + my $optlist = join(";", keys %$opts); my %filtered_opts = map { my $t=$_; $t=~s/[#\$]+$//; $t => $$opts{$_} } keys %$opts; - my @l = `bin/config $defargs $section $optlist`; + my @l = `bin/config $defargs "$section\{$optlist\}"`; $? && exit 1; foreach my $o (@l) { - $o =~ /^CF_([^=]+)='(.*)'\n$/ or die "Cannot parse bin/config output: $_"; + $o =~ /^CF_.*_([^=]+)='(.*)'\n$/ or die "Cannot parse bin/config output: $_"; my $var = $filtered_opts{$1}; my $val = $2; if (ref $var eq "SCALAR") { @@ -41,7 +44,7 @@ sub Parse(@) { } elsif (ref $var eq "ARRAY") { push @$var, $val; } elsif (ref $var) { - die ("Sherlock::Config::Parse: don't know how to set $o"); + die ("UCW::Config::Parse: don't know how to set $o"); } } }