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 Jun 27, 2024
1 parent f2f7e12 commit 564a872
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions lib/Synergy/Reactor/InABox.pm
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,23 @@ 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};
}
}

# 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{datacentre} && exists $switches{datacenter}) {
return await $event->error_reply("You can't use /datacentre and /datacenter at the same time!");
}

if (exists $switches{datacenter}) {
$switches{datacentre} = delete $switches{datacenter};
if (exists $switches{datacenter} || exists $switches{region}) {
return await $event->error_reply("Please pass only one of /datacenter or /datacentre or /region!");
}

for my $k (qw( version tag size datacentre )) {
Expand Down

0 comments on commit 564a872

Please sign in to comment.