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
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")
}