(minor) usage() sub can handle multiple usage sections in the same script
This commit is contained in:
parent
84422ccf30
commit
cbd4d43687
|
@ -75,10 +75,12 @@ sub _die {
|
||||||
}
|
}
|
||||||
|
|
||||||
sub usage {
|
sub usage {
|
||||||
_warn(shift) if @_;
|
my ($warn, $section) = @_;
|
||||||
|
_warn($warn) if $warn;
|
||||||
|
$section ||= 'usage';
|
||||||
my $scriptname = ( caller() )[1];
|
my $scriptname = ( caller() )[1];
|
||||||
my $script = slurp($scriptname);
|
my $script = slurp($scriptname);
|
||||||
$script =~ /^=for usage(.*?)^=cut/sm;
|
$script =~ /^=for $section(.*?)^=cut/sm;
|
||||||
say2( $1 ? $1 : "...no usage message in $scriptname" );
|
say2( $1 ? $1 : "...no usage message in $scriptname" );
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue