aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Vigier <boklm@mars-attacks.org>2013-10-07 17:10:39 +0200
committerNicolas Vigier <boklm@mars-attacks.org>2013-10-07 17:10:39 +0200
commitf6e7618153610805af91c0b4a3f43d18737f52fc (patch)
tree8434c13eaa8d659fc79b8d0381cf838db9c84e9f
parentf2c7434ae5a29d348ba0c9c2baa3f08278d937b8 (diff)
Allow the showconf command to query specific options
-rwxr-xr-xmgagit23
1 files changed, 20 insertions, 3 deletions
diff --git a/mgagit b/mgagit
index a9387ae..63aa5ce 100755
--- a/mgagit
+++ b/mgagit
@@ -38,9 +38,12 @@ END
run => \&showconf,
descr => 'Show YAML mgagit configuration',
usage => <<END,
-$0 showconf
+$0 showconf [reponame] [optionname]
-Show YAML mgagit configuration
+Show the mgagit configuration. If given one argument, it will display
+the configuration for the specified repo. If given two argument, it
+will display the value of the specified option for the specified repo.
+Without any argument, it displays all the configuration.
END
},
);
@@ -90,9 +93,23 @@ sub glrun {
}
sub showconf {
+ shift;
+ my $res;
my %r;
MGA::Git::load_gitrepos(\%r);
- print YAML::Dump(\%r);
+ usageexit('usage', 'showconf') if @_ > 2;
+ if (@_ == 1) {
+ $res = YAML::Dump($r{repos}{$_[0]});
+ } elsif (@_ == 2) {
+ $res = MGA::Git::repo_config(\%r, @_);
+ $res .= "\n" if defined $res;
+ } else {
+ my $c = $MGA::Git::config;
+ $c->{r} = \%r;
+ $res = YAML::Dump($c);
+ }
+ print defined $res ? $res : "undef\n";
+ exit !defined $res;
}
if (@ARGV == 0 || !$actions{$ARGV[0]}) {