1 | #!/usr/bin/perl |
---|
2 | |
---|
3 | use strict; |
---|
4 | use warnings; |
---|
5 | use LATMOS::Accounts; |
---|
6 | use LATMOS::Accounts::Bases::OCHelper; |
---|
7 | use Getopt::Long; |
---|
8 | use Pod::Usage; |
---|
9 | |
---|
10 | # $Id: ochelper 2038 2010-04-17 14:39:41Z nanardon $ |
---|
11 | |
---|
12 | GetOptions( |
---|
13 | 'c|config=s' => \my $config, |
---|
14 | 'b|base=s' => \my $base, |
---|
15 | 'o|object=s' => \my $otype, |
---|
16 | 'e|empty' => \my $empty_attr, |
---|
17 | 'fmt=s' => \my $fmt, |
---|
18 | 'filefmt=s' => \my $filefmt, |
---|
19 | 'ro' => \my $with_ro, |
---|
20 | 'no-unexp|wo-unexp' => \my $nounexp, |
---|
21 | 'with-unexp' => \my $unexp, |
---|
22 | 'help' => sub { pod2usage(0) }, |
---|
23 | ) or pod2usage(); |
---|
24 | |
---|
25 | $otype ||= 'user'; |
---|
26 | |
---|
27 | my $LA = LATMOS::Accounts->new($config, noacl => 1); |
---|
28 | my $labase = $base ? $LA->base($base) : $LA->default_base; |
---|
29 | $labase && $labase->load or die "Cannot load base"; |
---|
30 | |
---|
31 | $labase->unexported($nounexp ? 0 : 1); |
---|
32 | |
---|
33 | my $helper = $labase->ochelper($otype); |
---|
34 | |
---|
35 | my $info = undef; |
---|
36 | while (1) { |
---|
37 | my $status; |
---|
38 | ($status, $info) = $helper->step($info); |
---|
39 | |
---|
40 | if ($status ne 'NEEDINFO') { |
---|
41 | if ($status eq 'CREATED') { |
---|
42 | print "Object created\n"; |
---|
43 | } else { |
---|
44 | print "Nothing done\n"; |
---|
45 | } |
---|
46 | last; |
---|
47 | } |
---|
48 | |
---|
49 | if ($info->{name}{ask}) { |
---|
50 | print "NAME:\n"; |
---|
51 | my $line = <STDIN>; |
---|
52 | chomp($line); |
---|
53 | $info->{name}{content} = $line; |
---|
54 | } |
---|
55 | foreach (@{$info->{ask} || []}) { |
---|
56 | print "$_ " . ($info->{contents}{$_} ? '(' . $info->{contents}{$_} . ')' : |
---|
57 | '-') . "\n"; |
---|
58 | my $line = <STDIN>; |
---|
59 | chomp($line); |
---|
60 | $info->{contents}{$_} = $line if($line); |
---|
61 | } |
---|
62 | } |
---|
63 | |
---|