Subject: | option dashifying bug? |
I'm trying to add in a --pager switch to perlcritic and I noticed an odd
behavior of the results from get_option(). I think the dashification at
the end is doubling up dashes.
0 windhund /usr/local/src/CPAN/Perl-Critic-1.090$ perl -dw
bin/perlcritic -1 --color --pager=less lib/Perl/Critic.pm
Loading DB routines from perl5db.pl version 1.28
Editor support available.
Enter h or `h h' for help, or `man perldebug' for more help.
main::(bin/perlcritic:33): our $VERSION = '1.090';
DB<1> x @ARGV
0 '-1'
1 '--color'
2 '--pager=less'
3 'lib/Perl/Critic.pm'
DB<2> c get_options
main::get_options(bin/perlcritic:71):
71: my %opts = _parse_command_line();
DB<3> n
main::get_options(bin/perlcritic:72):
72: _dispatch_special_requests( %opts );
DB<3> c 103
main::get_options(bin/perlcritic:103):
103: return %dashed_opts;
DB<4> x \%opts
0 HASH(0x1ab8570)
'-color' => 1
1 => 1
'color' => 1
'pager' => 'less'
'severity' => 1
DB<5> x \%dashed_opts
0 HASH(0x1ab8930)
'--color' => 1
'-1' => 1
'-color' => 1
'-pager' => 'less'
'-severity' => 1
Note how there's a --color (which is the default set in
_parse_command_line()) and -color which is what was set on the command
line. This duplication makes using the result from get_options()
difficult without first running it through Perl::Critic->new and
accessing it via the config object.
This is a problem because I would like to open and use a pager before
loading Perl::Critic, so any printing necessary before that point can
use the pager. I might wind up with $options{pager} or $options{-pager}
or $options{--pager}.
What to do?