Subject: | Bug/Feature request: Support of special-case handling |
Date: | Sun, 10 Dec 2017 18:07:53 +0100 |
To: | bug-Getopt-Long-Complete [...] rt.cpan.org |
From: | Sebastian Schleussner <sebastian [...] schleussner.name> |
*Distribution name*: Getopt-Long-Complete-0.30
*Perl version*: 5.26
*OS*: CYGWIN_NT-10.0 bornholm 2.9.0(0.318/5/3) 2017-09-12 10:18 x86_64 Cygwin
Thank you for GLC!
Getopt::Long allows specifying "right-hand sides" for certain options, even when
using a hashref as the first argument. One use case is a coderef for parameter
verification of a particular option. (Unfortunately I don't see it spelled out
in the package's current documentation. I do make heavy use of it in my scripts
and can attest that it is fully working, though.)
Code example:
#!/usr/bin/env perl
use strict;
use warnings;
use Getopt::Long::Complete;
my %Opts;
GetOptions( \%Opts
, 'foo'
, 'demo=s' => \$Opts{abc}
, 'help' => sub { print "Usage: $0 [--demo A] [--foo]\n"; exit; }
) or die;
print "abc: $Opts{abc}\n";
print "foo: $Opts{foo}\n";
Execution:
Show quoted text
> ./demo.pl --foo --demo bar
abc: bar
foo: 1
Show quoted text > COMP_LINE="demo.pl -" COMP_POINT=9 ./demo.pl
Can't parse option spec 'CODE(0x600153928)' at
/usr/local/share/perl5/site_perl/5.26/Complete/Getopt/Long.pm line 302.
Fix: See attached Complete.patch.
Best regards,
Sebastian Schleussner
Message body is not shown because sender requested not to inline it.