Langertha-Knarr

 view release on metacpan or  search on metacpan

lib/Langertha/Knarr/CLI.pm  view on Meta::CPAN



# MooX::Options maps a dashed long option (--log-file) to its underscore
# attribute (log_file), but its argv rewrite takes the token after a
# boolean flag as that flag's value and passes it through unmapped — so
# `--from-env --log-file X` reached Getopt::Long as `--log-file` and died
# with "Unknown option". Map every long option name up front; arguments
# not starting with `--` and everything after a bare `--` are left alone.
around new_with_cmd => sub {
  my ( $orig, $class, @args ) = @_;
  local @ARGV = $class->normalize_argv(@ARGV);
  return $class->$orig(@args);
};

sub normalize_argv {
  my ( $class, @argv ) = @_;
  my @out;
  while (@argv) {
    my $arg = shift @argv;
    if ( $arg eq '--' ) {
      push @out, $arg, @argv;



( run in 3.173 seconds using v1.01-cache-2.11-cpan-145b269f2f3 )