Created
October 15, 2010 02:25
-
-
Save xaicron/627490 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/jperl | |
use strict; | |
use warnings; | |
use Getopt::Compact::WithCmd; | |
use Data::Dumper; | |
my $go = Getopt::Compact::WithCmd->new( | |
modes => [qw/verbose/], | |
global_struct => [ | |
[ [qw/o output/], 'output filename', '=s', undef, { required => 1 } ], | |
], | |
command_struct => { | |
foo => { | |
options => [ | |
[ [qw/d define/], 'define variables', '=s%', undef, { required => 1 } ], | |
], | |
desc => 'this is foo', | |
}, | |
}, | |
); | |
my $opt = $go->opts; | |
my $cmd = $go->command || '';; | |
print "opt: ", Dumper $opt; | |
print "command: $cmd\n"; | |
print "\@ARGV: ", Dumper \@ARGV; | |
__END__ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/jperl | |
use strict; | |
use warnings; | |
use Getopt::Compact::WithCmd; | |
use Data::Dumper; | |
my $go = Getopt::Compact::WithCmd->new( | |
modes => [qw/verbose/], | |
global_struct => [ | |
[ [qw/o output/], 'output filename', '=s', undef, { required => 1 } ], | |
], | |
); | |
my $opt = $go->opts; | |
print "opt: ", Dumper $opt; | |
print "\@ARGV: ", Dumper \@ARGV; | |
__END__ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/jperl | |
use strict; | |
use warnings; | |
use Getopt::Compact::WithCmd; | |
use Data::Dumper; | |
my $go = Getopt::Compact::WithCmd->new( | |
global_struct => [ | |
[ [qw/v verbose/], 'verbose mode' ], | |
], | |
command_struct => { | |
foo => { | |
options => [ | |
[ [qw/d define/], 'define variables', '=s%', undef, { default => { hoge => 'fuga' } } ], | |
], | |
desc => 'this is foo', | |
command_struct => { | |
bar => { | |
options => [ | |
[ [qw/f force/], 'force overwrite' ], | |
], | |
desc => 'bar', | |
}, | |
}, | |
}, | |
hoge => { | |
desc => 'Hoge Hoge', | |
}, | |
}, | |
); | |
my $opt = $go->opts; | |
my $cmd = $go->command || ''; | |
my $cmds = $go->commands; | |
print "opt: ", Dumper $opt; | |
print "command: $cmd\n"; | |
print "commands: ", Dumper $cmds; | |
print "\@ARGV: ", Dumper \@ARGV; | |
__END__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment