blob: 039d6b45d5f35e76f890d6602345c7f3778e367a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
#!/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 );
};
};
|