plucky (3) Commandable::Command.3pm.gz

Provided by: libcommandable-perl_0.14-1_all bug

NAME

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

DESCRIPTION

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

ACCESSORS

       The following simple methods return metadata fields about the command

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

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

   arguments
          @args = $command->arguments;

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

   options
          %opts = $command->options;

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

   package
          $pkg = $command->package;

       The package name as a plain string.

   code
          $sub = $command->code;

       A CODE reference to the code actually implementing the command.

METHODS

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

ARGUMENT SPECIFICATIONS

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

   name
   description
          $name = $argspec->name;

          $desc = $argspec->description;

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

   optional
          $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.

   slurpy
          $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.

OPTION SPECIFICATIONS

       Each option specification is given by an object having the following 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 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
          @names = $optspec->names;

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

   description
          $desc = $optspec->description;

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

   mode
          $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.

   default
          $val = $optspec->default;

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

   negatable
          $bool = $optspec->negatable;

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

   typespec
       Since version 0.13 no longer supported.

   matches
          $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").

AUTHOR

       Paul Evans <leonerd@leonerd.org.uk>