From 3749aadcc2490272914e47bdd3130c7e8a0e1212 Mon Sep 17 00:00:00 2001 From: Philipp Grau Date: Fri, 1 Nov 2013 11:34:20 +0100 Subject: [PATCH] Use Pod::Usage to allow --help -\? and --man to read the docs in a simpler way --- bin/icli | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bin/icli b/bin/icli index 88a37df..6d02324 100755 --- a/bin/icli +++ b/bin/icli @@ -15,6 +15,7 @@ use List::MoreUtils qw(any firstval); use POSIX qw(strftime); use Term::ANSIColor; use Term::Size; +use Pod::Usage; our $VERSION = '0.46'; @@ -36,6 +37,8 @@ my $term_width = Term::Size::chars(); my $cut_mode = 'b'; my ( @for_hosts, @for_groups, @for_services, @list_hosts, @list_services ); my @filters; +my $help; +my $man; sub have_host { my ($host) = @_; @@ -934,8 +937,13 @@ GetOptions( 'V|version' => sub { say "icli version $VERSION"; exit 0 }, 'x|cut-mode=s' => sub { $cut_mode = substr( $_[1], 0, 1 ) }, 'z|filter=s' => sub { push( @filters, split( /,/, $_[1] ) ) }, + 'help|?' => \$help, + 'man' => \$man, ) or die("Please see perldoc -F $0 for help\n"); +pod2usage(1) if $help; +pod2usage(-verbose => 2) if $man; + read_objects( $status_file, \$data ); read_objects( $config_file, \$config ); enhance_status();