Dyer::CLI - useful subs for coding cli scripts
This standardizes some things like expecting that if the -v flag is used, that means they want version. That if they want -h, they want help. Etc.
This package must be used as base.
use base 'DYER::CLI';
prompt user for y/n confirmation will loop until it returs true or false argument is the question for the user
yn('continue?') or exit;
will force program to exit if user if whoami is not root.
returns array ref of argument variables treated as paths, they are resolved with Cwd::abs_path() Any arguments that do not resolve, are skipped with a warning. if no abs paths are present after checking, returns undef files are checked for existence returns undef if no @ARGVS or none of the args are on disk skips over files not on disk with warnings
Same as argv_aspaths(), but returns false if any of the file arguments are no longer on disk
Same as argv_aspaths(), but does not check for existence, only resolved to abs paths
returns name of script, just the name.
will print manual and exit.
returns hash of options uses Getopt::Std, forces v for version, h for help
To get standard with v and h:
my $o = gopts();
To add options
my $o = gopts('af:');
Adds a (bool) and f(value), v and h are still enforced.
Leo Charre leocharre at cpan dot org
This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself, i.e., under the terms of the "Artistic License" or the "GNU General Public License".
Copyright (c) 2007 Leo Charre. All rights reserved.