1 | #!/usr/bin/perl |
---|
2 | |
---|
3 | use strict; |
---|
4 | use warnings; |
---|
5 | use LATMOS::Accounts; |
---|
6 | use Getopt::Long; |
---|
7 | use Pod::Usage; |
---|
8 | |
---|
9 | =head1 NAME |
---|
10 | |
---|
11 | la-config - Tools to query configuration of LATMOS::Accounts system. |
---|
12 | |
---|
13 | =head1 SYNOPSIS |
---|
14 | |
---|
15 | List setup base, synchronisation |
---|
16 | |
---|
17 | la-config [option] |
---|
18 | |
---|
19 | =cut |
---|
20 | |
---|
21 | GetOptions( |
---|
22 | 'c|config=s' => \my $config, |
---|
23 | 'ls' => \my $listsynchros, |
---|
24 | 'base=s' => \my $base, |
---|
25 | 'help' => sub { pod2usage(0) }, |
---|
26 | ) or pod2usage(); |
---|
27 | |
---|
28 | =head1 OPTIONS |
---|
29 | |
---|
30 | =over 4 |
---|
31 | |
---|
32 | =item -c|--config configdir |
---|
33 | |
---|
34 | Use this configuration directory instead of the default one. |
---|
35 | |
---|
36 | =item -b|--base basename |
---|
37 | |
---|
38 | Perform query on this base |
---|
39 | |
---|
40 | =item --ls |
---|
41 | |
---|
42 | List synchronisation setup in config |
---|
43 | |
---|
44 | =back |
---|
45 | |
---|
46 | =cut |
---|
47 | |
---|
48 | my $LA = LATMOS::Accounts->new($config, noacl => 1); |
---|
49 | |
---|
50 | if ($listsynchros) { |
---|
51 | my $default_sync = $LA->default_synchro_name || ''; |
---|
52 | print "Syncro:\n"; |
---|
53 | foreach ($LA->list_synchro) { |
---|
54 | printf(" %s %s (%s => %s)\n", |
---|
55 | ($_ eq $default_sync ? '*' : ' '), |
---|
56 | $_, |
---|
57 | $LA->val("sync:$_", 'from', 'Err: No from'), |
---|
58 | join(', ', $LA->val("sync:$_", 'to', 'Err: No to')), |
---|
59 | ); |
---|
60 | } |
---|
61 | } else { |
---|
62 | my $default = $LA->default_base_name || ''; |
---|
63 | print "Bases:\n"; |
---|
64 | foreach ($LA->list_bases) { |
---|
65 | printf(" %s %s (%s)\n", |
---|
66 | ($_ eq $default ? '*' : ' '), |
---|
67 | $_, |
---|
68 | $LA->val($_, 'type', 'Err: no type') |
---|
69 | ); |
---|
70 | } |
---|
71 | } |
---|