3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-10-04 18:38:47 +02:00

Add quotes around keys in more places

This commit is contained in:
Pragmatic Software 2018-08-09 10:55:53 -07:00
parent 1bedb74720
commit 5fe46db2ce

View File

@ -254,13 +254,15 @@ sub set {
my $secondary = $self->find_index($primary, $secondary_index_key); my $secondary = $self->find_index($primary, $secondary_index_key);
if (not $secondary) { if (not $secondary) {
my $result = "No such $self->{name} object [$primary_index_key] $secondary_index_key; similiar matches: "; my $secondary_text = $secondary_index_key =~ / / ? "\"$secondary_index_key\"" : $secondary_index_key;
my $result = "No such $self->{name} object [$primary_index_key] $secondary_text; similiar matches: ";
$result .= $self->levenshtein_matches($primary, $secondary_index_key); $result .= $self->levenshtein_matches($primary, $secondary_index_key);
return $result; return $result;
} }
if (not defined $key) { if (not defined $key) {
my $result = "[" . ($primary eq '.*' ? 'global' : $primary) . "] $secondary keys:\n"; my $secondary_text = $secondary =~ / / ? "\"$secondary\"" : $secondary;
my $result = "[" . ($primary eq '.*' ? 'global' : $primary) . "] $secondary_text keys:\n";
my $comma = ''; my $comma = '';
foreach my $key (sort keys %{ $self->hash->{$primary}->{$secondary} }) { foreach my $key (sort keys %{ $self->hash->{$primary}->{$secondary} }) {
$result .= $comma . "$key => " . $self->hash->{$primary}->{$secondary}->{$key}; $result .= $comma . "$key => " . $self->hash->{$primary}->{$secondary}->{$key};
@ -278,6 +280,7 @@ sub set {
} }
$primary = 'global' if $primary eq '.*'; $primary = 'global' if $primary eq '.*';
$secondary = "\"$secondary\"" if $secondary =~ / /;
return "[$primary] $secondary: '$key' " . (defined $value ? "set to '$value'" : "is not set."); return "[$primary] $secondary: '$key' " . (defined $value ? "set to '$value'" : "is not set.");
} }
@ -304,6 +307,7 @@ sub unset {
$self->save(); $self->save();
$primary = 'global' if $primary eq '.*'; $primary = 'global' if $primary eq '.*';
$secondary = "\"$secondary\"" if $secondary =~ / /;
return "[$self->{name}] ($primary) $secondary: '$key' unset."; return "[$self->{name}] ($primary) $secondary: '$key' unset.";
} }