Spinach: add set/unset commands to modify metadata

This commit is contained in:
Pragmatic Software 2019-04-23 18:22:52 -07:00
parent 781faa678b
commit 0b0390dbd7
1 changed files with 27 additions and 1 deletions

View File

@ -233,7 +233,7 @@ sub spinach_cmd {
my ($self, $from, $nick, $user, $host, $arguments) = @_;
$arguments =~ s/^\s+|\s+$//g;
my $usage = "Usage: spinach join|exit|ready|unready|choose|lie|reroll|skip|score|show|categories|filter|kick|abort; for more information about a command: spinach help <command>";
my $usage = "Usage: spinach join|exit|ready|unready|choose|lie|reroll|skip|score|show|categories|filter|set|unset|kick|abort; for more information about a command: spinach help <command>";
my $command;
($command, $arguments) = split / /, $arguments, 2;
@ -312,6 +312,14 @@ sub spinach_cmd {
return "Help is coming soon.";
}
when ('set') {
return "Help is coming soon.";
}
when ('unset') {
return "Help is coming soon.";
}
default {
if (length $arguments) {
return "Spinach has no such command '$arguments'. I can't help you with that.";
@ -862,6 +870,24 @@ sub spinach_cmd {
}
}
when ('set') {
my ($index, $key, $value) = split /\s+/, $arguments;
if (not defined $index) {
return "Usage: spinach set <metadata> [key [value]]";
}
return $self->{metadata}->set($index, $key, $value);
}
when ('unset') {
my ($index, $key) = split /\s+/, $arguments;
if (not defined $index or not defined $key) {
return "Usage: spinach unset <metadata> <key>";
}
return $self->{metadata}->unset($index, $key);
}
default {
return $usage;
}