GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Commandable::Command(3) User Contributed Perl Documentation Commandable::Command(3)

"Commandable::Command" - represent metadata for an invokable command

Objects in this class are returned by a Commandable::Finder instance to represent individual commands that exist.

The following simple methods return metadata fields about the command

   $name = $command->name;
   $desc = $command->description;

Strings giving the short name (to be used on a commandline), and descriptive text for the command.

   @args = $command->arguments;

A (possibly-empty) list of argument metadata structures.

   %opts = $command->options;

A (possibly-empty) kvlist of option metadata structures.

   $pkg = $command->package;

The package name as a plain string.

   $sub = $command->code;

A CODE reference to the code actually implementing the command.

Since version 0.12 this method has been moved to Commandable::Finder.

Each argument specification is given by an object having the following structure:

   $name = $argspec->name;
   $desc = $argspec->description;

Text strings for the user, used to generate the help text.

   $bool = $argspec->optional;

If false, the option is mandatory and an error is raised if no value is provided for it. If true, it is optional and if absent an "undef" will passed instead.

   $bool = $argspec->slurpy;

If true, the argument will be passed as an ARRAY reference containing the entire remaining list of tokens provided by the user.

Each option specification is given by an object having the following structure:

   $name = $optspec->name;

A string giving the primary human-readable name of the option.

   $keyname = $optspec->keyname;

A string giving the name this option will be given in the options hash provided to the command subroutine. This is generated from the human-readable name, but hyphens are converted to underscores, to make it simpler to use as a hash key in Perl code.

   @names = $optspec->names;

A list containing the name plus all the aliases this option is known by.

   $desc = $optspec->description;

A text string containing information for the user, used to generate the help text.

   $mode = $optspec->mode;

A string that describes the behaviour of the option.

"set" options do not expect a value to be suppled by the user, and will 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; values are pushed into an ARRAY reference which is passed in the options hash.

"inc" options may be supplied more than once; each occurance will increment the stored value by one.

   $val = $optspec->default;

A value to provide in the options hash if the user did not specify a different one.

   $bool = $optspec->negatable;

If true, also accept a "--no-OPT" option to reset the value of the option to "undef".

Since version 0.13 no longer supported.

   $re = $optspec->matches;

If defined, gives a precompiled regexp that any user-supplied value must conform to.

A few shortcuts are provided, which are used if the provided name ends in "=i" (for "integer"), "=u" (for "unsigned integer", i.e. non-negative) or "=f" (for "float").

Paul Evans <leonerd@leonerd.org.uk>

2025-07-03 perl v5.40.2

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.