diff --git a/README.md b/README.md index 2723382f..c743e6d0 100644 --- a/README.md +++ b/README.md @@ -146,9 +146,9 @@ when isMainModule: dispatchMulti([foo, help={"myRequired": "Need it!"}], [bar]) ``` With the above in `cmd.nim`, CLI users can run `./cmd foo -m1` or -`./cmd bar -y10 1.0 2.0`. `./cmd` with no arguments prints a brief help message -while `./cmd help` prints a comprehensive message, and `./cmd SUBCMD --help` or -`./cmd help SUBCMD` print a message for just `SUBCMD` (e.g. `foo`|`bar`). +`./cmd bar -y10 1.0 2.0`. `./cmd` or `./cmd --help` print brief help messages +while `./cmd help` prints a comprehensive message, and `./cmd SUBCMD --help` +or `./cmd help SUBCMD` print a message for just `SUBCMD` (e.g. `foo`|`bar`). Like long option keys or `enum` value names, subcommand names can also be ***any unambiguous prefix and are case-kebab-insensitive***. So, `./cmd f-O -m1` would diff --git a/cligen.nim b/cligen.nim index 8f7c412f..003c5267 100644 --- a/cligen.nim +++ b/cligen.nim @@ -548,10 +548,10 @@ macro dispatchGen*(pro: typed{nkSym}, cmdName: string="", doc: string="", `cf`.helpAttrOff.getOrDefault(tag, "")) let use = if `noHdrId`: - if `cf`.use.len > 0: `cf`.use else: `usageId` + if `usageId`.len > 0: `usageId` else: `cf`.use else: (if `cf`.useHdr.len > 0: `cf`.useHdr else: clUseHdr) & - (if `cf`.use.len > 0: `cf`.use else: `usageId`) + (if `usageId`.len > 0: `usageId` else: `cf`.use) let argStart = "[" & (if `mandatory`.len>0: `apId`.val4req&"," else: "") & "optional-params]" `apId`.help = use % ["doc", hl("doc", indentDoc),