Changeset 1446 in ProjectBuilder


Ignore:
Timestamp:
Apr 4, 2012, 5:14:48 PM (12 years ago)
Author:
ebaudrez
Message:

`verbose' mode is really debug mode

Remove the command-line flag `-v' (sorry). Instead, provide a
command-line flag `-d', which prints out useful information for
debugging. Rename the `inbox' only when not debugging.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • projects/md2mb/devel/md2mb/bin/md2mb.pl

    r1445 r1446  
    2323# Is the newroot a file (1) or a dir (0)
    2424my $nrisfile = 0;
     25# END CHANGE
    2526my $debug = 0;
    26 # END CHANGE
    2727my $help = 0;
    2828my $man = 0;
     
    3030# parse command-line options
    3131GetOptions(
     32    'debug|d'   => \$debug,
    3233    'help|h'    => \$help,
    3334    'man|m'     => \$man,
    34     'verbose|v' => sub { $debug++ },
    3535) or pod2usage(2);
    3636pod2usage(1) if ($help);
    3737pod2usage(-exitstatus => 0, -verbose => 2) if ($man);
    3838
    39 print "DEBUG MODE, not doing anything, just printing\n" if ($debug);
     39# debug mode overview
     40if ($debug) {
     41    print <<EOF;
     42DEBUG MODE, not doing anything, just printing
     43--- current state ---
     44cmd     = $cmd
     45oldroot = $oldroot
     46newroot = $newroot
     47--- end ---
     48EOF
     49}
     50
     51# create destination path
    4052if ($debug) {
    4153    print "TARGET DIR: mkdir -p $newroot\n" if ((not -d "$newroot") && (not $nrisfile));
     
    4658system("$cmd </dev/null >/dev/null 2>/dev/null") == 0 or die "cannot find formail on your \$PATH!\nTry installing procmail\nAborting";
    4759
     60# the main work is done here
     61if ($debug) {
     62    print "DESCENDING INTO oldroot($oldroot)\n";
     63}
    4864find(\&md2mb,($oldroot));
    4965
     66# rename `inbox' to `Inbox'
    5067if ((-z "$newroot/Inbox") || (! -e "$newroot/Inbox")) {
    51     print "Renaming inbox into Inbox\n";
    52     move("$newroot/inbox","$newroot/Inbox") if (-e "$newroot/inbox");
     68    if ($debug) {
     69        print "RENAMING inbox($newroot/inbox) INTO Inbox($newroot/Inbox)\n" if (-e "$newroot/inbox");
     70    } else {
     71        print "Renaming inbox into Inbox\n";
     72        move("$newroot/inbox","$newroot/Inbox") if (-e "$newroot/inbox");
     73    }
    5374}
    5475
     
    134155
    135156 Options:
    136    -help        brief help message
    137    -man         full documentation
     157   -debug | -d      debug mode
     158   -help | -h       brief help message
     159   -man | -m        full documentation
    138160
    139161=head1 OPTIONS
    140162
    141163=over 4
     164
     165=item B<-debug>
     166
     167Enter debug mode. This will print what would be done. No commands are executed,
     168so this is safe to use when testing.
    142169
    143170=item B<-help>
Note: See TracChangeset for help on using the changeset viewer.