From d2630e5ae9a129083c8f1e6296d12a70c9e21e15 Mon Sep 17 00:00:00 2001 From: Vladimir Mihailenco Date: Sat, 9 May 2020 17:34:50 +0300 Subject: [PATCH] Add Cmder.FullName --- command.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/command.go b/command.go index 7741cd20..44ef5fa2 100644 --- a/command.go +++ b/command.go @@ -14,6 +14,7 @@ import ( type Cmder interface { Name() string + FullName() string Args() []interface{} String() string stringArg(int) string @@ -151,6 +152,21 @@ func (cmd *baseCmd) Name() string { return internal.ToLower(cmd.stringArg(0)) } +func (cmd *baseCmd) FullName() string { + switch name := cmd.Name(); name { + case "cluster", "command": + if len(cmd.args) == 1 { + return name + } + if s2, ok := cmd.args[1].(string); ok { + return name + " " + s2 + } + return name + default: + return name + } +} + func (cmd *baseCmd) Args() []interface{} { return cmd.args }