#!/usr/bin/perl use strict; use warnings; use Piny; my ( $reponame, $attr, $value ) = @ARGV; if ( not defined $reponame ) { die "Usage: $0 reponame|--user [tweakable [value]]\n"; }; my $repo; my $config; my $env = Piny::Environment->instance( ); if ( $reponame eq "--user" ) { $config = $env->user->config; } else { $repo = Piny::Repo->new( $reponame ); $config = $repo->config; }; if ( not defined $attr ) { my $tweakables = $config->all_tweakables; foreach my $t ( sort keys %$tweakables ) { my $v = $tweakables->{$t}; if ( defined $v ) { print "$t => $v\n"; } else { print "$t undefined\n"; }; }; } else { $attr = lc $attr; $attr =~ s/\./_/g; if ( defined $value ) { unless ( $env->user->uid == 0 or $reponame eq "--user" or $repo->owner->uid == $env->user->uid ) { print "You are not the owner of that repo!\n"; exit( 3 ); }; 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"; exit( 4 ); }; if ( $value ne $config->$attr ) { print STDERR "Failed to set $attr (perhaps an override is in place)\n"; exit( 5 ); }; }; undef $@; eval { print "$attr = " . $config->$attr . "\n"; }; if ( $@ ) { print STDERR "$attr is not a legal tweakable, or its current value is illegal.\n$@\n"; exit( 6 ); }; };