From: Joey Hess Date: Sun, 14 Oct 2007 04:09:36 +0000 (-0400) Subject: add support for getting config settings X-Git-Url: https://git.madduck.net/code/myrepos.git/commitdiff_plain/54b2aa669527829d36eeb92dbda13977200d5545?hp=fb4c5ab3cf865b15d2092ccbc90aa5f7bd416c16 add support for getting config settings --- diff --git a/mr b/mr index b65e623..db209d2 100755 --- a/mr +++ b/mr @@ -86,9 +86,11 @@ directory to register. =item config -Modifies the mrconfig file. The next parameter is the name of the section -to add or modify, and it is followed by one or more instances of -"parameter=value". Use "parameter=" to remove a parameter. +Adds, modifies, removed, or prints a value from the mrconfig file. The next +parameter is the name of the section the value is in. To add or modify a +value, follow it by one or more instances of "parameter=value". Use +"parameter=" to remove a parameter. Use just "parameter" to get the value +of a parameter. For example, to add (or edit) a repository in src/foo: @@ -282,16 +284,21 @@ elsif ($action eq 'config') { $section=$1; } } - my %fields; + my %changefields; foreach (@ARGV) { if (/^([^=]+)=(.*)$/) { - $fields{$1}=$2; + $changefields{$1}=$2; } else { - die "mr config: expected parameter=value, not \"$_\"\n"; + foreach my $topdir (sort keys %config) { + if (exists $config{$topdir}{$section} && + exists $config{$topdir}{$section}{$_}) { + print $config{$topdir}{$section}{$_}."\n"; + } + } } } - modifyconfig($config, $section, %fields); + modifyconfig($config, $section, %changefields) if %changefields; exit 0; } elsif ($action eq 'register') {