source: LATMOS-Accounts/bin/la-delete @ 655

Last change on this file since 655 was 655, checked in by vivat, 14 years ago

Ajout d'un message d'erreur lorsqu'un parametre obligatoire n'est pas fourni

  • Property svn:executable set to *
  • Property svn:keywords set to Id Rev
File size: 1.2 KB
Line 
1#!/usr/bin/perl
2
3use strict;
4use warnings;
5use LATMOS::Accounts;
6use Getopt::Long;
7use Pod::Usage;
8
9=head1 NAME
10
11    la-delete - Tools to delete object in LATMOS-Accounts
12
13=head1 SYNOPSIS
14
15    la-delete [options] obj_id
16
17=cut
18
19GetOptions(
20    'c|config=s' => \my $config,
21    'b|base=s'   => \my $base,
22    'o|object=s' => \my $otype,
23    'help'       => sub { pod2usage(0) },
24) or pod2usage();
25
26$otype ||= 'user';
27
28=head1 OPTIONS
29
30=over 4
31
32=item -c|--config configfile
33
34Use this configuration file instead of the default one.
35
36=item -b|--base basename
37
38Query this specific base instead of the default one.
39
40=item -o|object object_type
41
42Query will be performed on this object. Default is the 'User' object.
43
44=back
45
46=cut
47
48if (!$ARGV[0]) {print "You must specify 'obj_id', aborting\n"; pod2usage(); }
49
50my $LA = LATMOS::Accounts->new($config, noacl => 1);
51my $labase = $base ? $LA->base($base) : $LA->default_base;
52$labase && $labase->load or die "Cannot load base";
53
54if ($labase->delete_object($otype, $ARGV[0])) {
55    $labase->commit;
56    print "$otype/$ARGV[0] succefully deleted\n";
57    $LA->call_batch_sync;
58} else {
59    warn "Cannot delete $otype/$ARGV[0]\n";
60    exit(1);
61}
Note: See TracBrowser for help on using the repository browser.