NAME
YA::CLI::ActionRole - Action handler role
VERSION
version 0.007
SYNOPSIS
package Foo;
use Moo;
with qw(YA::CLI::ActionRole);
sub usage_pod { 1 } # 1 Usage is provided by this module's POD
sub cli_options { return qw(foo=s) }
sub action { "action" }
sub subaction { "subaction" }
sub run { ...; }
DESCRIPTION
This role should be implemented by an action handler. The action handler should implement the following methods:
- action
-
The action it handles, eg.
provider
- run
-
How the action should be run
The following method doesn't need to be implemented if an action doesn't have a subcommand
- subaction
-
The sub action it handles, eg.
create
METHODS
usage_pod
If the handler provides its own usage POD. If this is 0/undef, the POD of the script it used. If this function returns 1, it it taken from the file itself. Otherwise it is assumed the return value is the path to the POD itself.
cli_options
Add additional CLI options for the sub command. This will be parsed by Getopt::Long.
get_opts
Parse the options and returns a hash with the parsed options.
as_help
Returns an YA::CLI::Usage object which runs as a help
as_manpage
Returns an YA::CLI::Usage object which runs as a manpage
has_action
Checks if the supplied action is supported by the action handler
new_from_args
Instantiates the class with the CLI args that were given to them
_cli_args
For all cli options which do not have attributes in the module, you can access them via
$self->_cli_args->{'your-name-here'}
AUTHOR
Wesley Schwengle <waterkip@cpan.org>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2022 by Wesley Schwengle.
This is free software, licensed under:
The (three-clause) BSD License