command.go: modifying Theme command to show all available themes (#232)

command.go: modifying Theme command to show all available themes
This commit is contained in:
Steven L 2017-05-07 17:48:08 -04:00 committed by Andrey Petrov
parent e800c88a56
commit 227dad7492

View File

@ -3,6 +3,7 @@ package chat
// FIXME: Would be sweet if we could piggyback on a cli parser or something.
import (
"bytes"
"errors"
"fmt"
"strings"
@ -180,7 +181,7 @@ func InitCommands(c *Commands) {
c.Add(Command{
Prefix: "/theme",
PrefixHelp: "[colors|...]",
Help: "Set your color theme. (More themes: solarized, mono, hacker)",
Help: "Set your color theme.",
Handler: func(room *Room, msg message.CommandMsg) error {
user := msg.From()
args := msg.Args()
@ -190,8 +191,16 @@ func InitCommands(c *Commands) {
if cfg.Theme != nil {
theme = cfg.Theme.ID()
}
body := fmt.Sprintf("Current theme: %s", theme)
room.Send(message.NewSystemMsg(body, user))
var output bytes.Buffer
fmt.Fprintf(&output, "Current theme: %s%s", theme, message.Newline)
fmt.Fprintf(&output, " Themes available: ")
for i, t := range message.Themes {
fmt.Fprintf(&output, t.ID())
if i < len(message.Themes)-1 {
fmt.Fprintf(&output, ", ")
}
}
room.Send(message.NewSystemMsg(output.String(), user))
return nil
}