Dyer::CLI - useful subs for coding cli scripts


Dyer-CLI documentation  | view source Contained in the Dyer-CLI distribution.

Index


NAME

Top

Dyer::CLI - useful subs for coding cli scripts

DESCRIPTION

Top

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.

USAGE

Top

This package must be used as base.

	use base 'DYER::CLI';

yn()

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;

force_root()

will force program to exit if user if whoami is not root.

argv_aspaths()

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

argv_aspaths_strict()

Same as argv_aspaths(), but returns false if any of the file arguments are no longer on disk

argv_aspaths_loose()

Same as argv_aspaths(), but does not check for existence, only resolved to abs paths

_scriptname()

returns name of script, just the name.

man()

will print manual and exit.

gopts()

Top

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.

AUTHOR

Top

Leo Charre leocharre at cpan dot org

LICENSE

Top

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

Top


Dyer-CLI documentation  | view source Contained in the Dyer-CLI distribution.