.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "App::Cmd::Command 3pm" .TH App::Cmd::Command 3pm "2023-09-24" "perl v5.36.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" App::Cmd::Command \- a base class for App::Cmd commands .SH "VERSION" .IX Header "VERSION" version 0.336 .SH "PERL VERSION" .IX Header "PERL VERSION" This library should run on perls released even a long time ago. It should work on any version of perl released in the last five years. .PP Although it may work on older versions of perl, no guarantee is made that the minimum required version will not be increased. The version may be increased for any reason, and there is no promise that patches will be accepted to lower the minimum required perl. .SH "METHODS" .IX Header "METHODS" .SS "prepare" .IX Subsection "prepare" .Vb 1 \& my ($cmd, $opt, $args) = $class\->prepare($app, @args); .Ve .PP This method is the primary way in which App::Cmd::Command objects are built. Given the remaining command line arguments meant for the command, it returns the Command object, parsed options (as a hashref), and remaining arguments (as an arrayref). .PP In the usage above, \f(CW$app\fR is the App::Cmd object that is invoking the command. .SS "new" .IX Subsection "new" This returns a new instance of the command plugin. Probably only \f(CW\*(C`prepare\*(C'\fR should use this. .SS "execute" .IX Subsection "execute" .Vb 1 \& $command_plugin\->execute(\e%opt, \e@args); .Ve .PP This method does whatever it is the command should do! It is passed a hash reference of the parsed command-line options and an array reference of left over arguments. .PP If no \f(CW\*(C`execute\*(C'\fR method is defined, it will try to call \f(CW\*(C`run\*(C'\fR \*(-- but it will warn about this behavior during testing, to remind you to fix the method name! .SS "app" .IX Subsection "app" This method returns the App::Cmd object into which this command is plugged. .SS "usage" .IX Subsection "usage" This method returns the usage object for this command. (See Getopt::Long::Descriptive). .SS "command_names" .IX Subsection "command_names" This method returns a list of command names handled by this plugin. The first item returned is the 'canonical' name of the command. .PP If this method is not overridden by an App::Cmd::Command subclass, it will return the last part of the plugin's package name, converted to lowercase. For example, YourApp::Cmd::Command::Init will, by default, handle the command \&\*(L"init\*(R". .PP Subclasses should generally get the superclass value of \f(CW\*(C`command_names\*(C'\fR and then append aliases. .SS "usage_desc" .IX Subsection "usage_desc" This method should be overridden to provide a usage string. (This is the first argument passed to \f(CW\*(C`describe_options\*(C'\fR from Getopt::Long::Descriptive.) .PP If not overridden, it returns \*(L"%c \s-1COMMAND\s0 \f(CW%o\fR\*(R"; \s-1COMMAND\s0 is the first item in the result of the \f(CW\*(C`command_names\*(C'\fR method. .SS "opt_spec" .IX Subsection "opt_spec" This method should be overridden to provide option specifications. (This is list of arguments passed to \f(CW\*(C`describe_options\*(C'\fR from Getopt::Long::Descriptive, after the first.) .PP If not overridden, it returns an empty list. .SS "validate_args" .IX Subsection "validate_args" .Vb 1 \& $command_plugin\->validate_args(\e%opt, \e@args); .Ve .PP This method is passed a hashref of command line options (as processed by Getopt::Long::Descriptive) and an arrayref of leftover arguments. It may throw an exception (preferably by calling \f(CW\*(C`usage_error\*(C'\fR, below) if they are invalid, or it may do nothing to allow processing to continue. .SS "usage_error" .IX Subsection "usage_error" .Vb 1 \& $self\->usage_error("This command must not be run by root!"); .Ve .PP This method should be called to die with human-friendly usage output, during \&\f(CW\*(C`validate_args\*(C'\fR. .SS "abstract" .IX Subsection "abstract" This method returns a short description of the command's purpose. If this method is not overridden, it will return the abstract from the module's Pod. If it can't find the abstract, it will look for a comment starting with \&\*(L"\s-1ABSTRACT:\*(R"\s0 like the ones used by Pod::Weaver::Section::Name. .SS "description" .IX Subsection "description" This method can be overridden to provide full option description. It is used by the built-in help command. .PP If not overridden, it uses Pod::Usage to extract the description from the module's Pod \s-1DESCRIPTION\s0 section or the empty string. .SH "AUTHOR" .IX Header "AUTHOR" Ricardo Signes .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2023 by Ricardo Signes. .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.