From: Mischa POSLAWSKY Date: Thu, 5 Sep 2019 01:02:38 +0000 (+0200) Subject: short and long help options X-Git-Tag: v1.01~17 X-Git-Url: http://git.shiar.net/barcat.git/commitdiff_plain/2ef7a03a58be7a955cd3cb6974d6583b7f10a584 short and long help options Emulate git commands in having -h for usage distinct from --help for full documentation. --- diff --git a/graph b/graph index 16af69a..f9d18a9 100755 --- a/graph +++ b/graph @@ -6,8 +6,11 @@ use List::Util qw( max sum ); our $VERSION = '1.00'; use Getopt::Long '2.33'; +sub podexit { require Pod::Usage; Pod::Usage::pod2usage(-exitval => 0, @_) } GetOptions(\my %opt, 'width|w=i', + 'usage|h' => sub { podexit() }, + 'help' => sub { podexit(-verbose => 2) }, ) or exit 64; # EX_USAGE $opt{width} ||= $ENV{COLUMNS} || 80;