docopt.coffee icon indicating copy to clipboard operation
docopt.coffee copied to clipboard

Docopt prints usage instead of parsing arguments

Open jrop opened this issue 8 years ago • 0 comments

The following example prints the usage and exits, instead of correctly parsing the arguments.

const {docopt} = require("docopt")

const usage = `
A description for my_program

Usage:
  my_program (--param1 PARAM1 | -x PARAM1)
             (--param2 PARAM2 | -y PARAM2)
             [--db DB]
             [--user USER | -u USER]
             [--password PASSWORD | -p PASSWORD]
  my_program (-h | --help | -v | --version)

Options:
  -h --help      Print this help message
  -v --version   Print version
`

const argv = docopt(usage, {
    argv: ['--param1', 'P1', '--param2', 'P2'],
    version: '1.0.0'
})
console.log(argv)

Expected output:

The python version works

jrop avatar Mar 14 '17 20:03 jrop