Ignore:
Timestamp:
01/21/10 02:33:29 (14 years ago)
Author:
nanardon
Message:
  • ask user to confirm object deletion
File:
1 edited

Legend:

Unmodified
Added
Removed
  • LATMOS-Accounts/bin/la-delete

    r664 r685  
    2121    'b|base=s'   => \my $base, 
    2222    'o|object=s' => \my $otype, 
     23    'force'      => \my $force, 
    2324    'help'       => sub { pod2usage(0) }, 
    2425) or pod2usage(); 
     
    4243Query will be performed on this object. Default is the 'User' object. 
    4344 
     45=item --force 
     46 
     47Do not ask confirmation before deleting 
     48 
    4449=back 
    4550 
     
    5358$labase->wexported(1); 
    5459 
     60if (!$labase->get_object($otype, $ARGV[0])) { 
     61    die "Cannot find object $otype $ARGV[0]\n"; 
     62} 
     63 
     64if (!$force) { 
     65    my $alea = int(rand(1000)); 
     66    print "Deleting object is definitive !\n"; 
     67    print "Are you sure you want to delete objet $otype $ARGV[0] ?\n"; 
     68    print "To confirm please enter this number: $alea\n"; 
     69    my $enter = <STDIN>; 
     70    chomp($enter); 
     71    if (!($enter =~ /^\d+$/ && $enter == $alea)) { 
     72        die "Wonrg input, aborting\n"; 
     73    } 
     74} 
     75 
    5576if ($labase->delete_object($otype, $ARGV[0])) { 
    5677    $labase->commit; 
Note: See TracChangeset for help on using the changeset viewer.