Subject: | Boolean values and Help menu |
Date: | Wed, 11 Mar 2015 10:32:03 -0700 |
To: | bug-Getopt-ArgParse [...] rt.cpan.org |
From: | Alexander Hartoto <ahartoto [...] gmail.com> |
Hi,
I'm using Perl 5.20.1 (Linux, SUSE 10 and SUSE11), and I'm facing the
following problem:
1. It doesn't seem like it's possible to hide an option from the help menu.
In Python's argparse we can have:
...
help=argparse.SUPPRESS,
...
It'd be nice if we can do this.
2. It doesn't seem like it's possible to have boolean options (both the
enable and disable) registered to the parser when both of them have the
same 'dest'.
my $ENABLE_CALLBACK = [
'--enable-callback',
type => 'Bool',
default => 1,
help => 'enable callback', # Ideally, I'd like to hide this because I
want it to be enabled by default
default => 'enable_callback',
];
my $NO_CALLBACK = [
'--no-callback',
type => 'Bool',
help => 'disable callback',
default => 'enable_callback',
];
In Python, we can specify 'store_true' and 'store_false' for action kwarg.
So, I guess that's how we can register both, and the first argument which
argparse encounters will determine the default value. Similar behavior will
be nice if we can enable it.
3. Incorrect display of the positional argument in the help menu (but the
parsing is still correct).
For example, if I'm expecting the positional argument specified after all
options:
my $CBARGS = [
'cbargs',
nargs => '*',
help => 'callback arguments',
metavar => 'cbarg',
];
If I register $ENABLE_CALLBACK and $CBARGS, what's going to be displayed is
going to be:
COMMAND [cbargs] [--enable-callback]
instead of
COMMAND [--enable-callback] [cbargs]
Alex