Skip to content

Commit

Permalink
InABox: Add support for /region alias for /datacentre
Browse files Browse the repository at this point in the history
I always type "/region" on the first try because I've spent too much
time in the cloud so region is the natural concept in my head rather
than datacentre. So let's make the robot accomodate the human.
  • Loading branch information
lerlacher-fm committed Jul 12, 2024
1 parent ef522db commit c18948f
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions lib/Synergy/Reactor/InABox.pm
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use Process::Status;
use Synergy::CommandPost;
use Synergy::Logger '$Logger';
use Synergy::Util qw(bool_from_text reformat_help);
use String::Switches qw(parse_switches);
use String::Switches qw(parse_switches canonicalize_names);
use JSON::MaybeXS;
use Future::Utils qw(repeat);
use Text::Template;
Expand Down Expand Up @@ -157,18 +157,12 @@ command box => {
my ($switches, $error) = parse_switches($args);
return await $event->error_reply("couldn't parse switches: $error") if $error;

my %switches = map { my ($k, @rest) = @$_; $k => \@rest } @$switches;

# This should be simplified into a more generic "validate and normalize
# switches" call. -- rjbs, 2023-10-20
# Normalize datacentre
if (exists $switches{datacentre} && exists $switches{datacenter}) {
return await $event->error_reply("You can't use /datacentre and /datacenter at the same time!");
}
canonicalize_names($switches, {
datacenter => 'datacentre',
region => 'datacentre'
});

if (exists $switches{datacenter}) {
$switches{datacentre} = delete $switches{datacenter};
}
my %switches = map { my ($k, @rest) = @$_; $k => \@rest } @$switches;

for my $k (qw( version tag size datacentre )) {
next unless $switches{$k};
Expand Down

0 comments on commit c18948f

Please sign in to comment.