| Getopt::Complete::Args - a set of option/value pairs |
Getopt::Complete::Args - a set of option/value pairs
This document describes Getopt::Complete::Args 0.25.
This is used internally by Getopt::Complete during compile.
A hand-built implementation might use the objects directly, and look like this:
# process @ARGV... my $args = Getopt::Complete::Args->new( options => [ # or pass a Getopt::Complete::Options directly 'myfiles=s@' => 'f', 'name' => 'u', 'age=n' => undef, 'fast!' => undef, 'color' => ['red','blue','yellow'], ] argv => \@ARGV );
$args->options->handle_shell_completion; # support 'complete -C myprogram myprogram'
if (my @e = $args->errors) { for my $e (@e) { warn $e; } exit 1; }
# on to normal running of the program...
for my $name ($args->option_names) { my $spec = $args->option_spec($name); my $value = $args->value($name); print "option $name has specification $spec and value $value\n"; }
An object of this class describes a set of option/value pairs, built from a the Getopt::Complete::Options manpage object and a list of command-line arguments (@ARGV).
This is the class of the $Getopt::Complete::ARGS object, and $ARGS alias created at compile time. It is also the source of the %ARGS hash injected into both of those namepaces at compile time.
Returns the list of original command-line arguments.
Returns the the Getopt::Complete::Options manpage object which was used to parse the command-line.
value($option_name)
Returns the value for a given option name after parsing.
Returns the bare arguments. The same as ->value('<>')
When using a tree of sub-commands, gives the list of sub-commands selected, in order to get to this point. The options and option/value pairs apply to just this particular sub-command.
The same as ->value('>').
Distinct from ->sub_commands(), which returns the list of next possible choices when
drilling down.
option_spec($name)
Returns the GetOptions specification for the parameter in question.
completion_handler($name)
Returns the arrayref or code ref which handles resolving valid completions.
The list of sub-commands which are options at this level of a command tree.
This is distinct from sub_command_path, which are the sub-commands which were chosen to get to this level in the tree.
the Getopt::Complete manpage, the Getopt::Complete::Options manpage, the Getopt::Complete::Compgen manpage
Copyright 2010 Scott Smith and Washington University School of Medicine
Scott Smith (sakoht at cpan .org)
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
| Getopt::Complete::Args - a set of option/value pairs |