Add Cmder.FullName

This commit is contained in:
Vladimir Mihailenco 2020-05-09 17:34:50 +03:00
parent 3031343dae
commit d2630e5ae9
1 changed files with 16 additions and 0 deletions

View File

@ -14,6 +14,7 @@ import (
type Cmder interface { type Cmder interface {
Name() string Name() string
FullName() string
Args() []interface{} Args() []interface{}
String() string String() string
stringArg(int) string stringArg(int) string
@ -151,6 +152,21 @@ func (cmd *baseCmd) Name() string {
return internal.ToLower(cmd.stringArg(0)) 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{} { func (cmd *baseCmd) Args() []interface{} {
return cmd.args return cmd.args
} }