From ad9a0efea993c293d1991fd1fcc426fb66d0a521 Mon Sep 17 00:00:00 2001 From: Leon Timmermans Date: Wed, 18 Jun 2025 01:08:09 +0200 Subject: [PATCH] Allow action after arguments Currently Module::Build::Tiny requires that the action comes before the arguments. This was strictly necessary before we deprecated .modulebuildrc files at the 2013 QAH in Lancaster. I should emphasize, the Build.PL spec only specifies the [action options] order, not the [options actions] order, so Module::Build::Tiny isn't quite wrong, and if we change things here we should probably also update the spec. Alternatively, we could issue a warning if anything is left in @ARGV after argument parsing, which would suggest that argument isn't being used. --- lib/Module/Build/Tiny.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Module/Build/Tiny.pm b/lib/Module/Build/Tiny.pm index 85fd2e9..7136b0b 100644 --- a/lib/Module/Build/Tiny.pm +++ b/lib/Module/Build/Tiny.pm @@ -176,10 +176,10 @@ sub get_arguments { } sub Build { - my $action = @ARGV && $ARGV[0] =~ /\A\w+\z/ ? shift @ARGV : 'build'; - die "No such action '$action'\n" if not $actions{$action}; my($env, $bargv) = @{ decode_json(read_file('_build_params')) }; my %opt = get_arguments($env, $bargv, \@ARGV); + my $action = @ARGV && $ARGV[0] =~ /\A\w+\z/ ? shift @ARGV : 'build'; + die "No such action '$action'\n" if not $actions{$action}; exit $actions{$action}->(%opt); }