source: trunk/LATMOS-Accounts/scripts/ochelper @ 1009

Last change on this file since 1009 was 861, checked in by nanardon, 13 years ago
  • reimport missing files from previous svn
  • Property svn:executable set to *
File size: 1.6 KB
Line 
1#!/usr/bin/perl
2
3use strict;
4use warnings;
5use LATMOS::Accounts;
6use LATMOS::Accounts::Bases::OCHelper;
7use Getopt::Long;
8use Pod::Usage;
9
10# $Id: ochelper 2038 2010-04-17 14:39:41Z nanardon $
11
12GetOptions(
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
27my $LA = LATMOS::Accounts->new($config, noacl => 1);
28my $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
33my $helper = $labase->ochelper($otype);
34
35my $info = undef;
36while (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
Note: See TracBrowser for help on using the repository browser.