NAME
Getopt::Chain - svn- and git-style option and subcommand processing
VERSION
Version 0.001_3
SYNPOSIS
#!/usr/bin/perl -w
use strict;
use Getopt::Chain;
Getopt::Chain->process(
options => [ qw/apple/ ],
run => sub {
my $context = shift;
# ... do stuff before grape or mango stuff ...
},
commands => {
grape => {
options => [ qw/banana:s/ ],
run => sub {
my $context = shift;
# ... do grape stuff ...
},
},
mango => {
run => sub {
my $context = shift;
# ... do mango stuff ..
},
},
},
)
# The above will allow the following (example) usage:
#
# ./script --apple mango
# ./script grape --banana ripe
# ./script --apple grape --banana ripe
DESCRIPTION
Getopt::Chain can be used to provide svn
- and git
-style option and subcommand processing. Any option specification covered by Getopt::Long is fair game.
This code is very, very new, so the API *might* change. Let me know if you're using it and have any suggestions.
TODO: Option descriptions (like Getopt::Long::Descriptive) and constraints (validation).
CAVEAT: Unfortunately, Getopt::Long slurps up the entire arguments array at once. Usually, this isn't a problem (as Getopt::Chain uses pass_through). However, if a subcommand has an option with the same name or alias as an option for a parent, then that option won't be available for the subcommand. For example:
./script --apple 1 <subcommand> --apple
# Getopt::Chain will not associate the second --apple with <subcommand>
So, for now, try to use distinct option names/aliases :)
METHODS
Getopt::Chain->process( <arguments>, ... )
<arguments> should be an ARRAY reference
Getopt::Chain->process( ... )
@ARGV will be used for <arguments>
SEE ALSO
AUTHOR
Robert Krimen, <rkrimen at cpan.org>
SOURCE
You can contribute or fork this project via GitHub:
http://github.com/robertkrimen/getopt-chain/tree/master
git clone git://github.com/robertkrimen/getopt-chain.git Getopt-Chain
BUGS
Please report any bugs or feature requests to bug-getopt-chain at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Getopt-Chain. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Getopt::Chain
You can also look for information at:
RT: CPAN's request tracker
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
ACKNOWLEDGEMENTS
COPYRIGHT & LICENSE
Copyright 2008 Robert Krimen, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.