From 7d84ab761ba6bf8a6fd4a652dfb8ac0efba3f0c9 Mon Sep 17 00:00:00 2001 From: John Guo Date: Mon, 13 Dec 2021 20:30:56 +0800 Subject: [PATCH] improve package gcmd for help content printing --- os/gcmd/gcmd_command_help.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/os/gcmd/gcmd_command_help.go b/os/gcmd/gcmd_command_help.go index de31ff97d..1d86f06dd 100644 --- a/os/gcmd/gcmd_command_help.go +++ b/os/gcmd/gcmd_command_help.go @@ -42,11 +42,14 @@ func (c *Command) Print() { name = p.parent.Name + " " + name p = p.parent } - if c.hasArgumentFromIndex() { - buffer.WriteString(fmt.Sprintf(`%s ARGUMENT [OPTION]`, name)) - } else { - buffer.WriteString(fmt.Sprintf(`%s [OPTION]`, name)) + buffer.WriteString(name) + if len(c.commands) > 0 { + buffer.WriteString(` COMMAND`) } + if c.hasArgumentFromIndex() { + buffer.WriteString(` ARGUMENT`) + } + buffer.WriteString(` [OPTION]`) } buffer.WriteString("\n\n") }