From c886c7e6daad3a58f218d694f1c37a033af71572 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 20 Dec 2010 21:42:35 +0100 Subject: Add usage statement --- bin/hashl | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/bin/hashl b/bin/hashl index 1117771..cfabccd 100755 --- a/bin/hashl +++ b/bin/hashl @@ -30,7 +30,7 @@ my $db; GetOptions( 'd|database=s' => \$db_file, 's|read-size=i' => sub { $read_size = $_[1] * 1024 }, -); +) or usage(); if (substr($db_file, 0, 1) ne '/') { $db_file = "${base}/${db_file}"; @@ -38,8 +38,16 @@ if (substr($db_file, 0, 1) ne '/') { my $action = $ARGV[0]; +sub usage { + die(<<"EOF"); +Usage: $0 [options] [args] +See 'perldoc -F $0' (or 'man $0' if it is properly installed) +EOF + +} + if (not defined $action) { - die("Usage: $0 \n"); + usage(); } if (-r $db_file) { @@ -206,6 +214,9 @@ elsif ($action eq 'info') { db_info(); } } +else { + usage(); +} __END__ @@ -215,7 +226,7 @@ B - Create database with partial file hashes, check if other files are in =head1 SYNOPSIS -B [B<-d> I] I [I] +B [B<-d> I] [B<-s> I] I [I] =head1 DESCRIPTION -- cgit v1.2.3