# HG changeset patch # User Matthias Förste foerste@schlittermann.de # Date 1316427157 -7200 # Node ID af8fc3e74ca075d031b4ae34d627a511debe4d17 # Parent a608df6cb0c11c3b79fb030ca36b4cae1013487c added options for --help and --man diff -r a608df6cb0c1 -r af8fc3e74ca0 bin/rpi --- a/bin/rpi Mon Sep 19 12:00:37 2011 +0200 +++ b/bin/rpi Mon Sep 19 12:12:37 2011 +0200 @@ -1,13 +1,34 @@ #!/usr/bin/perl +=encoding utf8 + +=cut + use warnings; use strict; use IO::File; use IPC::Run qw(run); +use Getopt::Long; use Mail::Sendmail; +use Pod::Usage; use Sys::Hostname::Long; +GetOptions( + "h|help" => sub { pod2usage(-exit => 0, -verbose => 1) }, + "m|man" => sub { + pod2usage( + -exit => 0, + -verbose => 2, + + # "system('perldoc -V &>/dev/null')" appears shorter, but may not + # do what you expect ( it still returns 0 on debian squeeze with + # dash as system shell even if cannot find the command in $PATH) + -noperldoc => system('perldoc -V >/dev/null 2>&1') + ); + } +) or pod2usage; + my $hostname = hostname_long; for (*STDERR, *STDOUT) { select $_; $|=1; } @@ -367,6 +388,13 @@ rpi - a wrapper around B +=head1 SYNOPSIS + +rpi + +rpi -m|--man + -h|--help + =head1 DESCRIPTION Until B supports a better mechanism for sending notifications for @@ -385,4 +413,8 @@ C<$fallback> address. Anything matching none of the defined patterns will be sent to the C<$fallback> address too. Everything will be printed to stdout. +=head1 AUTHORS + +Matthias Förste L<> + =cut