From 33e8ab11e8c87e1207e826ac3ea533c09cfb5a1e Mon Sep 17 00:00:00 2001 From: Lukas Erlacher Date: Fri, 28 Jun 2024 08:55:39 +1000 Subject: [PATCH] squashme --- lib/Synergy/Reactor/InABox.pm | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/lib/Synergy/Reactor/InABox.pm b/lib/Synergy/Reactor/InABox.pm index b597a3cd..c30de3a6 100644 --- a/lib/Synergy/Reactor/InABox.pm +++ b/lib/Synergy/Reactor/InABox.pm @@ -159,24 +159,16 @@ command box => { my %switches = map { my ($k, @rest) = @$_; $k => \@rest } @$switches; - if (!exists $switches{datacentre}) { - if (exists $switches{datacenter}) { - $switches{datacentre} = delete $switches{datacenter}; - } - elsif (exists $switches{region}) { - $switches{datacentre} = delete $switches{region}; - } - } + # Special handling for aliased datacenter / datacentre / region switch + my @got = grep { exists $switches{$_} } qw(datacenter datacentre region); - # This should be simplified into a more generic "validate and normalize - # switches" call. -- rjbs, 2023-10-20 - # I've made this not more generic but more clever: We first normalize to - # datacentre above and then check if one of the aliases is still hanging - # around which means a duplicate alias was passed. -- lerlacher, 2024-07-27 - # Normalize datacentre - if (exists $switches{datacenter} || exists $switches{region}) { - return await $event->error_reply("Please pass only one of /datacenter or /datacentre or /region!"); + if (@got > 1) { + return await $event->error_reply("The following options are mutually exclusive: @got\n"); } + elsif (@got > 0) { + $switches{datacentre} = delete $switches{$got[0]}; + } + for my $k (qw( version tag size datacentre )) { next unless $switches{$k};