From cfd894f446f356ed1c0fb37d88aee8c34bb4e40c Mon Sep 17 00:00:00 2001 From: Marco Molteni Date: Sun, 19 Jan 2020 19:40:53 +0100 Subject: usage: if the program supports subcommands, mention it --- usage.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'usage.go') diff --git a/usage.go b/usage.go index 57935fd..b07280b 100644 --- a/usage.go +++ b/usage.go @@ -88,6 +88,13 @@ func (p *Parser) writeUsageForCommand(w io.Writer, cmd *command) { fmt.Fprint(w, spec.placeholder) } } + + // if the program supports subcommands and the command-line doesn't contain any, + // give a hint to the user about the existence of these subcommands. + if len(p.cmd.subcommands) > 0 && p.cmd == cmd { + fmt.Fprint(w, " []") + } + fmt.Fprint(w, "\n") } -- cgit v1.2.3