From 38d5ef5603bba2241ec5ccf1c86f98ec24e023d6 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Wed, 17 Jun 2020 14:15:22 +0300 Subject: Add alias management command and alt_aliases rendering * /alias command can be used to create and remove local aliases * Changes to the alt_aliases are now rendered properly --- ui/command-processor.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'ui/command-processor.go') diff --git a/ui/command-processor.go b/ui/command-processor.go index 94b07b8..b8f41a2 100644 --- a/ui/command-processor.go +++ b/ui/command-processor.go @@ -41,11 +41,13 @@ type Command struct { Command string OrigCommand string Args []string + RawArgs string OrigText string } func (cmd *Command) Reply(message string, args ...interface{}) { cmd.Room.AddServiceMessage(fmt.Sprintf(message, args...)) + cmd.UI.Render() } type Alias struct { @@ -128,6 +130,7 @@ func NewCommandProcessor(parent *MainView) *CommandProcessor { "rainbow": cmdRainbow, "rainbowme": cmdRainbowMe, "notice": cmdNotice, + "alias": cmdAlias, "tags": cmdTags, "tag": cmdTag, "untag": cmdUntag, @@ -146,15 +149,22 @@ func (ch *CommandProcessor) ParseCommand(roomView *RoomView, text string) *Comma return nil } text = text[1:] - split := strings.SplitN(text, " ", -1) + split := strings.Fields(text) + command := split[0] + args := split[1:] + var rawArgs string + if len(text) > len(command)+1 { + rawArgs = text[len(command)+1:] + } return &Command{ gomuksPointerContainer: ch.gomuksPointerContainer, Handler: ch, Room: roomView, - Command: strings.ToLower(split[0]), - OrigCommand: split[0], - Args: split[1:], + Command: strings.ToLower(command), + OrigCommand: command, + Args: args, + RawArgs: rawArgs, OrigText: text, } } -- cgit v1.2.3