Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InABox: Add support for /region alias for /datacentre #236

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;

lerlacher-fm marked this conversation as resolved.
Show resolved Hide resolved
for my $k (qw( version tag size datacentre )) {
next unless $switches{$k};
Expand Down