0

folks!

I am trying the docopt (cpp variant). I have tried this variant:

  Usage:
    prog [-o | --out-file=<out-file>] <in-file>
    prog -h | --help
    prog --version

  Options:
    -h --help                  Show this screen.
    --version                  Show version.
    -o, --out-file=<out-file>  Output file name [default: stdout].
    <in-file>                  Input file.

I expected that docopt expects zero or one out-file option and it gives me a string as a result, but it can accept two or more this options and gives me a string-list value.

Is this right?

Serge Roussak
  • 1,731
  • 1
  • 14
  • 28

1 Answers1

0

I found that it works as expected when I corrected the command-line description like this:

Usage:
  prog [-o<out-file>|--out-file=<out-file>] <in-file>
  prog -h | --help
  prog --version

Options:
  -h --help                  Show this screen.
  --version                  Show version.
  -o, --out-file=<out-file>  Output file name [default: stdout].
  <in-file>                  Input file.

or even like this:

Usage:
  prog [-o<out-file>] <in-file>
  prog -h | --help
  prog --version

Options:
  -h --help                  Show this screen.
  --version                  Show version.
  -o, --out-file=<out-file>  Output file name [default: stdout].
  <in-file>                  Input file.
Serge Roussak
  • 1,731
  • 1
  • 14
  • 28