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

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

Ensure users cannot retrieve password, even encrypted

  • 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    base => $labase,
71    TransMode => $transmode ? 1 : 0,
72);
73
74my $Env = LATMOS::Accounts::Cli->new(
75    Context => $Context,
76);
77
78if (@ARGV) {
79    $Env->run(@ARGV);
80} else {
81     my $history = "$ENV{HOME}/.lacli_history";
82     $Env->Context->Term->ReadHistory($history);
83     $Env->cli;
84     if (! $Env->Context->Term->WriteHistory($history)) {
85         warn "Cannot write history:  $!\n";
86     }
87}
88print "\n";
89
90exit 0;
91
Note: See TracBrowser for help on using the repository browser.