added options for --help and --man rsync
authorMatthias Förste foerste@schlittermann.de
Mon, 19 Sep 2011 12:12:37 +0200
branchrsync
changeset 25 af8fc3e74ca0
parent 24 a608df6cb0c1
child 26 cb9cbd9ee35a
added options for --help and --man
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<reprepro processincoming>
 
+=head1 SYNOPSIS
+
+rpi
+
+rpi -m|--man
+    -h|--help
+
 =head1 DESCRIPTION
 
 Until B<reprepro> 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<<foerste@schlittermann.de>>
+
 =cut