Getopt...::Args(3pm)
π NAME π
Getopt::Complete::Args β a whole little set of option/value pairs, bestie π
π¦ VERSION π¦
This doc is describing Getopt::Complete::Args version 0.26, periodt.
β¨ SYNOPSIS β¨
okay so real talk: this thing is used internally by Getopt::Complete when it compiles. Like, it's the backstage crew, not the main character. π
But if you wanna hand-build your own implementation and use the objects directly, it could look exactly 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 -F _getopt_complete 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";
}
like, slay. that's the whole vibe. π«Ά
πΈ DESCRIPTION πΈ
An object of this class is literally a set of option/value pairs π β and it's built from a Getopt::Complete::Options object plus a list of command-line arguments (@ARGV).
Not me telling you that this is the class of the $Getopt::Complete::ARGS object, and the $ARGS alias that gets created at compile time π«£ It's also the source of the %ARGS hash that gets injected into both of those namespaces at compile time. iconic behavior tbh.
π METHODS π
argv
Returns the list of original command-line arguments. the receipts, basically π
options
Returns the Getopt::Complete::Options object that was used to parse the command-line.
value($option_name)
Returns the value for a given option name, after parsing. yes queen, post-parse.
bare_args
Returns the bare arguments. it's the same as ->value('<>') π
parent_sub_commands
When you're using a tree of sub-commands, this gives you the list of sub-commands that were selected, in order, to get to this point. π The options and option/value pairs apply to just this particular sub-command.
It's the same as ->value('>').
β οΈ bestie this is distinct from ->sub_commands(), which returns the list of next possible choices when drilling down. don't mix them up, i'm begging π
option_spec($name)
Returns the GetOptions specification for the parameter in question.
completion_handler($name)
Returns the arrayref or code ref that handles resolving valid completions. she does the thinking for you π
sub_commands
The list of sub-commands which are options at this level of a command tree. π³
This is distinct from sub_command_path, which is the sub-commands that were chosen to get to this level in the tree. two different things, both slaying π
π₯ SEE ALSO π₯
Getopt::CompleteGetopt::Complete::OptionsGetopt::Complete::Compgen
go read those too, iykyk π
β COPYRIGHT β
Copyright 2010 Scott Smith and Washington University School of Medicine
π AUTHORS π
Scott Smith (sakoht at cpan .org)
π LICENSE π
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.
and that's the whole page, bestie!! πβ¨ this was Getopt...::Args(3pm) from the User Contributed Perl Documentation, perl v5.36.0, dated 2022-10-13. mwah, go forth and parse π
π
π¦ where this page comes from
- ubuntu noble: libgetopt-complete-perl 0.26-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libgetopt-complete-perl 0.26-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libgetopt-complete-perl 0.26-4 Β· 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