diff options
author | Tulir Asokan <tulir@maunium.net> | 2020-06-17 14:15:22 +0300 |
---|---|---|
committer | Tulir Asokan <tulir@maunium.net> | 2020-06-17 14:15:22 +0300 |
commit | 38d5ef5603bba2241ec5ccf1c86f98ec24e023d6 (patch) | |
tree | 79dd23058b6598756c876e16e93e6cc9b0ba1d65 /ui/command-processor.go | |
parent | a8b6abe9703f0df95757686ca9340c697eca0f43 (diff) |
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
Diffstat (limited to 'ui/command-processor.go')
-rw-r--r-- | ui/command-processor.go | 18 |
1 files changed, 14 insertions, 4 deletions
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, } } |