diff options
author | Nicolas Vigier <boklm@mars-attacks.org> | 2013-10-07 17:10:39 +0200 |
---|---|---|
committer | Nicolas Vigier <boklm@mars-attacks.org> | 2013-10-07 17:10:39 +0200 |
commit | f6e7618153610805af91c0b4a3f43d18737f52fc (patch) | |
tree | 8434c13eaa8d659fc79b8d0381cf838db9c84e9f | |
parent | f2c7434ae5a29d348ba0c9c2baa3f08278d937b8 (diff) | |
download | mgagit-f6e7618153610805af91c0b4a3f43d18737f52fc.tar mgagit-f6e7618153610805af91c0b4a3f43d18737f52fc.tar.gz mgagit-f6e7618153610805af91c0b4a3f43d18737f52fc.tar.bz2 mgagit-f6e7618153610805af91c0b4a3f43d18737f52fc.tar.xz mgagit-f6e7618153610805af91c0b4a3f43d18737f52fc.zip |
Allow the showconf command to query specific options
-rwxr-xr-x | mgagit | 23 |
1 files changed, 20 insertions, 3 deletions
@@ -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]}) { |