1 | #!/usr/bin/perl |
---|
2 | |
---|
3 | use strict; |
---|
4 | use warnings; |
---|
5 | use LATMOS::Accounts; |
---|
6 | use Getopt::Long; |
---|
7 | use Pod::Usage; |
---|
8 | use LATMOS::Accounts::Cli::Context; |
---|
9 | use LATMOS::Accounts::Cli; |
---|
10 | |
---|
11 | =head1 NAME |
---|
12 | |
---|
13 | la-cli - A powerfull commandline tool to manage LATMOS::Accounts contents |
---|
14 | |
---|
15 | =head1 SYNOPSIS |
---|
16 | |
---|
17 | la-cli [options] |
---|
18 | |
---|
19 | =cut |
---|
20 | |
---|
21 | GetOptions( |
---|
22 | 'c|config=s' => \my $config, |
---|
23 | 'b|base=s' => \my $base, |
---|
24 | 't|transaction' => \my $transmode, |
---|
25 | 'no-unexp|wo-unexp' => \my $nounexp, |
---|
26 | 'with-unexp' => \my $unexp, |
---|
27 | 'u|username=s' => \my $username, |
---|
28 | 'acls' => \my $acls, |
---|
29 | 'help' => sub { pod2usage(0) }, |
---|
30 | ) or pod2usage(); |
---|
31 | |
---|
32 | =head1 OPTIONS |
---|
33 | |
---|
34 | =over 4 |
---|
35 | |
---|
36 | =item -c|--config configdir |
---|
37 | |
---|
38 | Use this configuration directory instead of the default one. |
---|
39 | |
---|
40 | =item -b|--base basename |
---|
41 | |
---|
42 | Query this specific base instead of the default one. |
---|
43 | |
---|
44 | =item -t|--transaction |
---|
45 | |
---|
46 | Enable transaction mode: don't commit at earch command |
---|
47 | |
---|
48 | =item --unexp |
---|
49 | |
---|
50 | Take into account all objects (even non propagated ones, with attribute 'exported'=0) |
---|
51 | |
---|
52 | =item --no-unexp |
---|
53 | |
---|
54 | Take into account only propagated objects (attribute 'exported'=1) (default) |
---|
55 | |
---|
56 | =item -u|--username USER |
---|
57 | |
---|
58 | Simulated access like user USER is login |
---|
59 | |
---|
60 | =item alcs |
---|
61 | |
---|
62 | Load acls |
---|
63 | |
---|
64 | =back |
---|
65 | |
---|
66 | =cut |
---|
67 | |
---|
68 | my $LA = LATMOS::Accounts->new($config, noacl => ! $acls, username => $username ); |
---|
69 | my $labase = $LA->base($base); |
---|
70 | $labase && $labase->load or die "Cannot load base"; |
---|
71 | |
---|
72 | $labase->unexported($nounexp ? 0 : 1); |
---|
73 | |
---|
74 | my $Context = LATMOS::Accounts::Cli::Context->new( |
---|
75 | La => $LA, |
---|
76 | base => $labase, |
---|
77 | TransMode => $transmode ? 1 : 0, |
---|
78 | ); |
---|
79 | |
---|
80 | my $Env = LATMOS::Accounts::Cli->new( |
---|
81 | Context => $Context, |
---|
82 | ); |
---|
83 | |
---|
84 | if (@ARGV) { |
---|
85 | $Context->Interractive( 0 ); |
---|
86 | $Env->run(@ARGV); |
---|
87 | } else { |
---|
88 | $Env->topCli; |
---|
89 | } |
---|
90 | print "\n"; |
---|
91 | |
---|
92 | exit 0; |
---|
93 | |
---|