Pcore::Core::CLI
# redirect CLI processing sub CLI ($self) { return 'Other::Class'; } # CLI commands hub sub CLI { return ['Cmd1', 'Cmd2', 'Cmd::Modules::' ]; } # or sub CLI { return { abstract => 'Abstract description', help => <<'HELP', Full CLI help HELP cmd => ['Cmd1', 'Cmd2', 'Cmd::Modules::' ], }; } # CLI command class extends qw[Pcore::Core::CLI::Cmd]; sub CLI ($self) { return { name => 'command', abstract => 'abstract desc', help => undef, opt => {}, arg => {}, }; } sub CLI_VALIDATE ( $self, $opt, $arg, $rest ) { return; } sub CLI_RUN ( $self, $opt, $arg, $rest ) { return; }
CLI class can be either a CLI "commands hub" or "command". Command hub - only keep other CLI commands together, it doesn't do anything else. CLI command must be a instance of Pcore::Core::CLI::Cmd role.
Return CLI specification as Str, ArrayRef of HashRef. Str - name of class to redirect CLI processor to. ArrayRef - list of CLI commands classes or namespaces. HashRef - full CLI specification, where supported keys are:
cmd - CLI commands classes names or namespace. Namespace should be specified with '::' at the end, eg.: 'My::CLI::Packages::'. cmd can be Str or ArrayRef[Str];
abstract - short description;
help - full help, can be multiline string;
name - CLI command name, can be a Str or ArrayRef[Str], if command has aliases. If command name is not specified - if will be parsed from the last segment of the class name;
opt - HashRef, options specification;
arg - ArrayRef, arguments specification;
Should validate parsed CLI data and return Str in case of error or undef.
To install Pcore, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Pcore
CPAN shell
perl -MCPAN -e shell install Pcore
For more information on module installation, please visit the detailed CPAN module installation guide.