Getopt...inator(3pm)
β¨ NAME β¨
Getopt::Usaginator β conjure up a usage function for your applications π
(also known to the perl doc system as Getopt...inator(3pm), a User Contributed Perl Documentation page, and yes bestie the name is a whole vibe)
πΈ VERSION πΈ
version 0.0012
π¦ SYNOPSIS π¦
use Getopt::Usaginator <<_END_;
Usage: xyzzy <options>
--derp Derp derp derp
--durp Durp durp durp
-h, --help This usage
_END_
# The 'usage' subroutine is now installed
...
$options = parse_options( @ARGV ); # Not supplied by Usaginator
usage if $options{help}; # Print usage and exit with status 0
if ( ! $options{derp} ) {
# Print warning and usage and exit with status -1
usage "You should really derp";
}
if ( $options{durp} ) {
# Print warning and usage and exit with status 2
usage 2 => "--durp is not ready yet";
}
...
usage 3 # Print usage and exit with status 3
π DESCRIPTION π
Okay so Getopt::Usaginator is literally a tool for creating a handy usage subroutine for your commandline applications. That's it, that's the whole job. It's giving β¨specialistβ¨.
And like, super important, bestie: it does not do any option parsing. Not a single flag, not one. Zero. π It is best paired with Getopt::Long or any of the other myriad of option parsers, because it's the cute little usage-printer, not the parser. They're a duo. Main character energy plus supporting cast. π«Ά
π USAGE π
use Getopt::Usaginator <usage>
Install a usage subroutine configured with the <usage> text. Boom, it's just there now. β¨
$code = Getopt::Usaginator->usaginator( <usage> )
Return a subroutine configured with the <usage> text. Same energy, except you get the coderef handed to you instead. π
...
More advanced usage is possible, bestie β you just gotta peek under the hood for more information, iykyk. π
perldoc -m Getopt::Usaginator
An example:
use Getopt::Usaginator
# Called with the error
error => sub { ... },
# Called when usage printing is needed
usage => sub { ... },
...
;
π An example with Getopt::Long parsing π
use Getopt::Usaginator ...
sub run {
my $self = shift;
my @arguments = @_;
usage 0 unless @arguments;
my ( $help );
{
local @ARGV = @arguments;
GetOptions(
'help|h|?' => \$help,
);
}
usage 0 if $help;
...
}
π AUTHOR π
Robert Krimen <robertkrimen@gmail.com>
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2010 by Robert Krimen.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
And that's a wrap, bestie β this page was served up byperl v5.36.0on2022-11-19, and it lives in theGetopt...inator(3pm)corner of the User Contributed Perl Documentation. Periodt. πβ¨
π¦ where this page comes from
- debian bookworm: libgetopt-usaginator-perl 0.0012-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libgetopt-usaginator-perl 0.0012-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libgetopt-usaginator-perl 0.0012-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libgetopt-usaginator-perl 0.0012-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libgetopt-usaginator-perl 0.0012-3 Β· 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