From 5ee45828fa626595297c6249aa6652820016835a Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Tue, 26 Mar 2019 10:55:27 +0200 Subject: [PATCH] Cosmetic tweaks to the help messages --- confutils.nim | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/confutils.nim b/confutils.nim index f10d660..d651d97 100644 --- a/confutils.nim +++ b/confutils.nim @@ -53,7 +53,7 @@ proc describeCmdOptions(cmd: CommandDesc) = write "\n" proc showHelp(version: string, cmd: CommandDesc) = - let app = appName & " " & version + let app = appName write "Usage: ", styleBright, app if cmd.name.len > 0: write " ", cmd.name @@ -65,11 +65,15 @@ proc showHelp(version: string, cmd: CommandDesc) = write "\n\nThe following options are supported:\n\n" describeCmdOptions(cmd) + if cmd.defaultSubCommand != -1: + describeCmdOptions(cmd.subCommands[cmd.defaultSubCommand]) + if cmd.subCommands.len > 0: - write "\nAvailable sub-commands:\n\n" - for subcmd in cmd.subCommands: - write " ", styleBright, app, " ", subcmd.name, "\n\n" - describeCmdOptions(subcmd) + write "\nAvailable sub-commands:\n" + for i in 0 ..< cmd.subCommands.len: + if i != cmd.defaultSubCommand: + write "\n ", styleBright, app, " ", cmd.subCommands[i].name, "\n\n" + describeCmdOptions(cmd.subCommands[i]) write "\n" quit(0)