Skip to content

Commit

Permalink
A better resolution to #219 and
Browse files Browse the repository at this point in the history
also revert mistaken 929dd5d
  • Loading branch information
c-blake committed Dec 23, 2022
1 parent b2806a2 commit 3c0926c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions cligen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 3c0926c

Please sign in to comment.