Comman...ommand(3pm)
β¨ NAME β¨
okay so bestie, welcome to Commandable::Command β it's the vibe where we represent metadata for an invokable command. that's the whole thing. π
π DESCRIPTION π
so like, when a Commandable::Finder instance is out here doing its thing, it hands you back objects of this class. each one is a little glow-up for one individual command that exists. one object, one command, no cap. π¦
π ACCESSORS π
these are the simple methods, and they just return metadata fields about the command. they're giving "let me tell you about myself" energy. β¨
π« name
π« description
$name = $command->name;
$desc = $command->description;
two strings, bestie: the short name (that's the one you'd actually use on a commandline) and the description text that describes the command. π«Ά
π« arguments
@args = $command->arguments;
a list of argument metadata structures β possibly empty, no pressure. π
π« options
%opts = $command->options;
a kvlist of option metadata structures β also possibly empty, also no pressure. π§
π« package
$pkg = $command->package;
the package name, as a plain string. that's it, that's the method. π
π« code
$sub = $command->code;
a CODE reference pointing at the code that actually implements the command. the real main character. π
π METHODS π
πΈ parse_invocation
so since version 0.12 this method has been moved to Commandable::Finder. it doesn't live here anymore, she moved out. πβ¨
π ARGUMENT SPECIFICATIONS π
each argument specification is given by an object that has this structure, okay? here's the breakdown:
π« name
π« description
$name = $argspec->name;
$desc = $argspec->description;
text strings for the user β these get used to generate the help text. π
π« optional
$bool = $argspec->optional;
if it's false, the option is mandatory and an error gets raised if no value is provided for it. if it's true, it's optional, and if it's absent an undef will be passed instead. periodt. π
π« slurpy
$bool = $argspec->slurpy;
if this is true, the argument gets passed as an ARRAY reference containing the entire remaining list of tokens the user provided. it's hungry, it eats the rest. ππ½οΈ
β OPTION SPECIFICATIONS β
each option specification is given by an object with this structure:
π« name
$name = $optspec->name;
a string giving the primary human-readable name of the option. π
π« keyname
$keyname = $optspec->keyname;
a string giving the name this option gets in the options hash that's handed to the command subroutine. it's generated from the human-readable name, but the hyphens get converted to underscores β all so it's simpler to use as a hash key in Perl code. lowercase genius behaviour fr fr. π§ β¨
π« names
@names = $optspec->names;
a list containing the name plus all the aliases this option is known by. the whole friend group. π«Ά
π« description
$desc = $optspec->description;
a text string with info for the user, used to generate the help text. π¬
π« mode
$mode = $optspec->mode;
a string that describes the behaviour of the option. and listen, there are several flavours:
"set"options do not expect a value to be suppled by the user, and they'll store a true value in the options hash if present. β"value"options take a value from the rest of the token, or the next token:
--opt=value
--opt value
"multi_value"options can be supplied more than once; the values get pushed into anARRAYreference which is passed in the options hash. π"inc"options may be supplied more than once; each occurance will increment the stored value by one. π’
π« default
$val = $optspec->default;
a value to provide in the options hash if the user didn't specify a different one. the backup plan, the safety net. π₯Ί
π« negatable
$bool = $optspec->negatable;
if true, it also accepts a --no-OPT option to reset the value of the option to undef. the undo button, basically. π
π« typespec
since version 0.13, no longer supported. rip, she's gone. πποΈ
π« matches
$re = $optspec->matches;
if defined, this gives a precompiled regexp that any user-supplied value must conform to. no exceptions bestie. π¨
a few shortcuts are provided too, and they get used if the provided name ends in =i (for "integer"), =u (for "unsigned integer", i.e. non-negative) or =f (for "float"). cute little shorthands, iykyk. πΈ
π AUTHOR π
Paul Evans <leonerd@leonerd.org.uk> β king behaviour, honestly. π
okay so that's the whole page, and the cutest little sign-off: this one came from the User Contributed Perl Documentation, it's perl v5.40.0, dated 2024-09-08. slay, bye bestie! πβ¨ππ¦πΈπ
π¦ where this page comes from
- ubuntu resolute: libcommandable-perl 0.14-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libcommandable-perl 0.14-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms