source: trunk/LATMOS-Accounts/bin/la-cli @ 2393

Last change on this file since 2393 was 2285, checked in by nanardon, 5 years ago

Add lock/banpasswd functions

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 1.8 KB
Line 
1#!/usr/bin/perl
2
3use strict;
4use warnings;
5use LATMOS::Accounts;
6use Getopt::Long;
7use Pod::Usage;
8use LATMOS::Accounts::Cli::Context;
9use 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
21GetOptions(
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    'help'              => sub { pod2usage(0) },
29) or pod2usage();
30
31=head1 OPTIONS
32
33=over 4
34
35=item -c|--config configdir
36
37Use this configuration directory instead of the default one.
38
39=item -b|--base basename
40
41Query this specific base instead of the default one.
42
43=item -t|--transaction
44
45Enable transaction mode: don't commit at earch command
46
47=item --unexp
48
49Take into account all objects (even non propagated ones, with attribute 'exported'=0)
50
51=item --no-unexp
52
53Take into account only propagated objects (attribute 'exported'=1) (default)
54
55=item -u|--username USER
56
57Simulated access like user USER is login
58
59=back
60
61=cut
62
63my $LA = LATMOS::Accounts->new($config, noacl => $username ? 0 : 1);
64my $labase = $LA->base($base);
65$labase && $labase->load or die "Cannot load base";
66
67$labase->unexported($nounexp ? 0 : 1);
68
69my $Context = LATMOS::Accounts::Cli::Context->new(
70    La => $LA,
71    base => $labase,
72    TransMode => $transmode ? 1 : 0,
73);
74
75my $Env = LATMOS::Accounts::Cli->new(
76    Context => $Context,
77);
78
79if (@ARGV) {
80    $Context->Interractive( 0 );
81    $Env->run(@ARGV);
82} else {
83     my $history = "$ENV{HOME}/.lacli_history";
84     $Env->Context->Term->ReadHistory($history);
85     $Env->cli;
86     if (! $Env->Context->Term->WriteHistory($history)) {
87         warn "Cannot write history:  $!\n";
88     }
89}
90print "\n";
91
92exit 0;
93
Note: See TracBrowser for help on using the repository browser.