From cbd4d4368783a2990718658cf3f1b19d1abb3f20 Mon Sep 17 00:00:00 2001 From: Sitaram Chamarty Date: Mon, 12 Mar 2012 10:43:33 +0530 Subject: [PATCH] (minor) usage() sub can handle multiple usage sections in the same script --- src/Gitolite/Common.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Gitolite/Common.pm b/src/Gitolite/Common.pm index 3ac2301..eb4b6f1 100644 --- a/src/Gitolite/Common.pm +++ b/src/Gitolite/Common.pm @@ -75,10 +75,12 @@ sub _die { } sub usage { - _warn(shift) if @_; + my ($warn, $section) = @_; + _warn($warn) if $warn; + $section ||= 'usage'; my $scriptname = ( caller() )[1]; my $script = slurp($scriptname); - $script =~ /^=for usage(.*?)^=cut/sm; + $script =~ /^=for $section(.*?)^=cut/sm; say2( $1 ? $1 : "...no usage message in $scriptname" ); exit 1; }