diff options
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"; }; |