From 2ef7a03a58be7a955cd3cb6974d6583b7f10a584 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Thu, 5 Sep 2019 03:02:38 +0200 Subject: [PATCH] short and long help options Emulate git commands in having -h for usage distinct from --help for full documentation. --- graph | 3 +++ 1 file changed, 3 insertions(+) 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; -- 2.30.0