improve package gcmd for help content printing

This commit is contained in:
John Guo 2021-12-13 20:30:56 +08:00
parent 80daed6bdf
commit 7d84ab761b

View File

@ -42,11 +42,14 @@ func (c *Command) Print() {
name = p.parent.Name + " " + name name = p.parent.Name + " " + name
p = p.parent p = p.parent
} }
if c.hasArgumentFromIndex() { buffer.WriteString(name)
buffer.WriteString(fmt.Sprintf(`%s ARGUMENT [OPTION]`, name)) if len(c.commands) > 0 {
} else { buffer.WriteString(` COMMAND`)
buffer.WriteString(fmt.Sprintf(`%s [OPTION]`, name))
} }
if c.hasArgumentFromIndex() {
buffer.WriteString(` ARGUMENT`)
}
buffer.WriteString(` [OPTION]`)
} }
buffer.WriteString("\n\n") buffer.WriteString("\n\n")
} }