docopt.coffee
docopt.coffee copied to clipboard
Docopt prints usage instead of parsing arguments
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: