From 681344f391f6a752cc96210ecb3216c1f4515363 Mon Sep 17 00:00:00 2001 From: Julian Blake Kongslie Date: Wed, 11 May 2011 22:05:00 -0700 Subject: Support listing all tweakables. --- pinyadmin/sbin/pinyconfig | 48 +++++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 18 deletions(-) (limited to 'pinyadmin') 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"; }; -- cgit v1.2.3