diff options
author | Julian Blake Kongslie <jblake@omgwallhack.org> | 2011-05-11 22:05:00 -0700 |
---|---|---|
committer | Julian Blake Kongslie <jblake@omgwallhack.org> | 2011-05-11 22:05:00 -0700 |
commit | 681344f391f6a752cc96210ecb3216c1f4515363 (patch) | |
tree | ca848d213f67e9391ad1861330d527e3a226c18b /pinyadmin/sbin | |
parent | 3ca6564c2d95d12dff83cc645c280aa734ad19f8 (diff) | |
download | piny-code-681344f391f6a752cc96210ecb3216c1f4515363.tar.gz piny-code-681344f391f6a752cc96210ecb3216c1f4515363.zip |
Support listing all tweakables.
Diffstat (limited to 'pinyadmin/sbin')
-rwxr-xr-x | pinyadmin/sbin/pinyconfig | 48 |
1 files changed, 30 insertions, 18 deletions
diff --git a/pinyadmin/sbin/pinyconfig b/pinyadmin/sbin/pinyconfig index e78cf3c..8496cc7 100755 --- a/pinyadmin/sbin/pinyconfig +++ b/pinyadmin/sbin/pinyconfig @@ -7,13 +7,10 @@ use Piny; my ( $reponame, $attr, $value ) = @ARGV; -if ( not defined $reponame or not defined $attr ) { - die "Usage: $0 reponame|--user tweakable [value]\n"; +if ( not defined $reponame ) { + die "Usage: $0 reponame|--user [tweakable [value]]\n"; }; -$attr = lc $attr; -$attr =~ s/\./_/g; - my $config; if ( $reponame eq "--user" ) { @@ -22,23 +19,38 @@ if ( $reponame eq "--user" ) { $config = Piny::Repo->new( $reponame )->config; }; -if ( defined $value ) { +if ( not defined $attr ) { + + my $tweakables = $config->all_tweakables; + + foreach my $t ( sort keys %$tweakables ) { + print "$t => " . $tweakables->{$t} . "\n"; + }; + +} else { + + $attr = lc $attr; + $attr =~ s/\./_/g; + + if ( defined $value ) { + undef $@; + eval { + $config->$attr( $value ); + }; + if ( $@ ) { + print STDERR "$attr is not a legal tweakable, or $value is not a legal value for that tweakable.\n$@\n"; + }; + if ( $value ne $config->$attr ) { + print STDERR "Failed to set $attr (perhaps an override is in place)\n"; + }; + }; + undef $@; eval { - $config->$attr( $value ); + print "$attr = " . $config->$attr . "\n"; }; if ( $@ ) { - print STDERR "$attr is not a legal tweakable, or $value is not a legal value for that tweakable.\n$@\n"; + print STDERR "$attr is not a legal tweakable, or its current value is illegal.\n$@\n"; }; - if ( $value ne $config->$attr ) { - print STDERR "Failed to set $attr (perhaps an override is in place)\n"; - }; -}; -undef $@; -eval { - print "$attr = " . $config->$attr . "\n"; -}; -if ( $@ ) { - print STDERR "$attr is not a legal tweakable, or its current value is illegal.\n$@\n"; }; |