NAME
Pcore::Core::CLI
SYNOPSIS
# 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;
}
DESCRIPTION
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.
METHODS
CLI ($self)
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;
CLI_VALIDATE ( $self, $opt, $arg, $rest )
Should validate parsed CLI data and return Str in case of error or undef.