Unix and Linux Discussions Tagged with usage |
|
Thread / Thread Starter |
Last Post |
Replies |
Views |
Forum |
|
|
|
5 |
14,302 |
UNIX for Advanced & Expert Users |
|
|
|
6 |
10,180 |
UNIX for Advanced & Expert Users |
|
|
|
3 |
15,432 |
UNIX for Advanced & Expert Users |
|
|
|
2 |
6,079 |
UNIX for Beginners Questions & Answers |
|
|
|
7 |
7,183 |
Shell Programming and Scripting |
|
|
|
0 |
3,990 |
UNIX for Beginners Questions & Answers |
|
|
|
2 |
3,762 |
Programming |
|
|
|
10 |
13,423 |
Ubuntu |
|
|
|
5 |
1,556 |
Shell Programming and Scripting |
|
|
|
8 |
15,890 |
Shell Programming and Scripting |
|
|
|
4 |
2,230 |
UNIX for Beginners Questions & Answers |
|
|
|
3 |
1,733 |
UNIX for Beginners Questions & Answers |
|
|
|
5 |
3,440 |
UNIX for Advanced & Expert Users |
|
|
|
2 |
7,938 |
UNIX for Advanced & Expert Users |
|
|
|
7 |
16,314 |
UNIX for Dummies Questions & Answers |
|
|
|
2 |
2,774 |
Red Hat |
|
|
|
1 |
7,560 |
UNIX for Dummies Questions & Answers |
|
|
|
2 |
6,773 |
Filesystems, Disks and Memory |
|
|
|
0 |
2,353 |
OS X Support RSS |
|
|
|
6 |
8,167 |
Shell Programming and Scripting |
|
|
|
4 |
14,735 |
HP-UX |
|
|
|
0 |
3,132 |
UNIX and Linux RSS News |
|
|
|
3 |
6,869 |
AIX |
|
|
|
2 |
5,864 |
Programming |
|
|
|
2 |
2,463 |
UNIX for Dummies Questions & Answers |
|
|
|
4 |
2,563 |
Shell Programming and Scripting |
|
|
|
8 |
6,206 |
Shell Programming and Scripting |
|
|
|
2 |
4,419 |
UNIX and Linux Applications |
|
|
|
2 |
6,049 |
UNIX for Dummies Questions & Answers |
|
|
|
0 |
2,455 |
Solaris BigAdmin RSS |
|
|
|
5 |
3,498 |
UNIX for Dummies Questions & Answers |
|
|
|
6 |
2,140 |
Shell Programming and Scripting |
|
|
|
28 |
11,439 |
UNIX for Dummies Questions & Answers |
|
|
|
5 |
3,193 |
Shell Programming and Scripting |
|
|
|
7 |
41,038 |
UNIX for Advanced & Expert Users |
|
|
|
7 |
21,441 |
Shell Programming and Scripting |
|
|
|
6 |
4,315 |
UNIX for Advanced & Expert Users |
|
|
|
14 |
38,157 |
Gentoo |
|
|
|
3 |
4,845 |
UNIX for Advanced & Expert Users |
|
|
|
8 |
6,139 |
Programming |
Getopt::Usaginator(3pm) User Contributed Perl Documentation Getopt::Usaginator(3pm)
NAME
Getopt::Usaginator - Conjure up a usage function for your applications
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
Getopt::Usaginator is a tool for creating a handy usage subroutine for commandline applications
It does not do any option parsing, but is best paired with Getopt::Long or any of the other myriad of option parsers
USAGE
use Getopt::Usaginator <usage>
Install a "usage" subroutine configured with the <usage> text
$code = Getopt::Usaginator->usaginator( <usage> )
Return a subroutine configured with the <usage> text
...
More advanced usage is possible, peek under the hood for more information
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.
perl v5.10.1 2010-06-05 Getopt::Usaginator(3pm)