From 3bfe437aa1c75c82be381c35944de03f02396f91 Mon Sep 17 00:00:00 2001 From: Vincent Levigneron Date: Fri, 30 Jul 2021 14:34:07 +0200 Subject: [PATCH 1/2] Shorter help in case of invalid options. --- lib/Zonemaster/CLI.pm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/Zonemaster/CLI.pm b/lib/Zonemaster/CLI.pm index 3eb3f093..c18b9c55 100755 --- a/lib/Zonemaster/CLI.pm +++ b/lib/Zonemaster/CLI.pm @@ -11,11 +11,11 @@ use 5.014002; use strict; use warnings; -use version; our $VERSION = version->declare( "v3.3.0" ); +use version; our $VERSION = version->declare( "v3.4.0" ); use Locale::TextDomain 'Zonemaster-CLI'; use Moose; -with 'MooseX::Getopt'; +with 'MooseX::Getopt::GLD' => { getopt_conf => [ 'pass_through' ] }; use Zonemaster::Engine; use Zonemaster::Engine::Logger::Entry; @@ -288,6 +288,12 @@ sub run { my %counter; my $printed_something; + if ( $self->extra_argv ) { + print "Unknown option: ", join q{ }, @{$self->extra_argv}, "\n"; + print "Run \"zonemaster-cli -h\" to get the valid options\n"; + exit; + } + if ( $self->locale ) { undef $ENV{LANGUAGE}; $ENV{LC_ALL} = $self->locale; From 2b6f89c48db59cc70915f0902dbc6bc732eb8966 Mon Sep 17 00:00:00 2001 From: Vincent Levigneron Date: Fri, 30 Jul 2021 16:03:50 +0200 Subject: [PATCH 2/2] Fix extra_argv analyze --- lib/Zonemaster/CLI.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Zonemaster/CLI.pm b/lib/Zonemaster/CLI.pm index c18b9c55..fc801ed7 100755 --- a/lib/Zonemaster/CLI.pm +++ b/lib/Zonemaster/CLI.pm @@ -288,8 +288,8 @@ sub run { my %counter; my $printed_something; - if ( $self->extra_argv ) { - print "Unknown option: ", join q{ }, @{$self->extra_argv}, "\n"; + if ( grep /^-/, @{ $self->extra_argv } ) { + print "Unknown option: ", join( q{ }, grep /^-/, @{ $self->extra_argv } ), "\n"; print "Run \"zonemaster-cli -h\" to get the valid options\n"; exit; }