status-im / nim-confutils

Simplified handling of command line options and config files
Apache License 2.0
63 stars 16 forks source link

Description for command which is set as default is not shown #60

Open kdeme opened 1 year ago

kdeme commented 1 year ago

The description for the command which is set as default is not shown when doing --help. It is only shown when doing <command name> --help.

Snippet:

import
  confutils

type
  ExporterCmd* = enum
    exportCommand =
      "Some very important description, must read this!"
    printCommand =
      "Some description"

  ExporterConf* = object
    case cmd* {.
      command
      defaultValue: exportCommand .}: ExporterCmd
    of exportCommand:
      port* {.
        defaultValue: 1
        desc: "some port"
        name: "port" .}: uint16
    of printCommand:
      portP* {.
        defaultValue: 1
        desc: "some port"
        name: "port" .}: uint16

when isMainModule:
  let config = ExporterConf.load()

No important description to be seen:

$ ./test_conf --help
Usage: 

test_conf command
 --port  some port [=1].

Available sub-commands:

test_conf printCommand [OPTIONS]...

Some description.

The following options are available:

 --port  some port [=1].

Only seen when specifically using the command:

$ ./test_conf exportCommand --help
Usage: 

test_conf exportCommand [OPTIONS]...

Some very important description, must read this!.

The following options are available:

 --port      some port [=1].

And when removing the default:

./test_conf --help
Usage: 

test_conf command

Available sub-commands:

test_conf exportCommand [OPTIONS]...

Some very important description, must read this!.

The following options are available:

 --port  some port [=1].

test_conf printCommand [OPTIONS]...

Some description.

The following options are available:

 --port  some port [=1].