From 54b2aa669527829d36eeb92dbda13977200d5545 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 14 Oct 2007 00:09:36 -0400 Subject: [PATCH] add support for getting config settings --- mr | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) 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') { -- 2.39.2