Skip to content

Commit

Permalink
Adding the ability to add some dynamic pre and post help text
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanwills-optus committed Jul 31, 2020
1 parent 37c4d53 commit 11a8ae8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/Getopt/Alt.pm
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ has help_packages => (
is => 'rw',
isa => 'HashRef[Str]',
);
has help_pre => (
is => 'rw',
isa => 'CodeRef',
);
has help_post => (
is => 'rw',
isa => 'CodeRef',
);
has helper => (
is => 'rw',
isa => 'Bool',
Expand Down Expand Up @@ -577,7 +585,7 @@ sub _show_help {
}

require Tie::Handle::Scalar;
my $out = '';
my $out = $self->help_pre ? $self->help_pre() : '';
tie *FH, 'Tie::Handle::Scalar', \$out;
require Pod::Usage;
Pod::Usage::pod2usage(
Expand All @@ -587,6 +595,7 @@ sub _show_help {
-output => \*FH,
%input,
);
$out .= $self->help_post ? $self->help_post->() : '';
die Getopt::Alt::Exception->new( message => $out, help => 1 );
}

Expand Down

0 comments on commit 11a8ae8

Please sign in to comment.