Skip to content

Commit

Permalink
update docopt.coffee to match docopt v0.6.2
Browse files Browse the repository at this point in the history
This adds some missing functionality added in previous versions of docopt
to completely fulfilf both the language agnostic testcases
`testcases.docopt` from `docopt/docopt`.

Further this adds some improvements for error handling (exiting the
process and printing to console in normal usage vs
throwing exceptions to catch them in unit tests).
  • Loading branch information
amtrack committed Apr 12, 2015
1 parent 0b5cb72 commit 7558e30
Show file tree
Hide file tree
Showing 2 changed files with 390 additions and 335 deletions.
8 changes: 6 additions & 2 deletions README.md
Expand Up @@ -36,7 +36,7 @@ pass to the `docopt` function.
API `{docopt} = require 'docopt'`
---------------------------------

### `options = docopt(doc, {argv: process.argv[2..], help: true, version: null, options_first: false})`
### `options = docopt(doc, {argv: process.argv[2..], help: true, version: null, options_first: false, exit: true})`

`docopt` takes 1 required argument, and 3 optional keyword arguments:

Expand Down Expand Up @@ -68,13 +68,17 @@ version of your program. If supplied, then, if the parser encounters
`version` could be any printable object, but most likely a string,
e.g. `'2.1.0rc1'`.

* `options_first`, by default `False`. If set to `True` will
* `options_first`, by default `false`. If set to `true` will
disallow mixing options and positional argument. I.e. after first
positional argument, all arguments will be interpreted as positional
even if the look like options. This can be used for strict
compatibility with POSIX, or if you want to dispatch your arguments
to other programs.

* `exit`, by default `true`. If set to `false` will
cause docopt to throw exceptions instead of printing the error to console and terminating the application.
This flag is mainly for testing purposes.

**Note:** Although `docopt` automatically handles `-h`, `--help` and `--version` options,
you still need to mention them in the options description (`doc`) for your users to
know about them.
Expand Down

0 comments on commit 7558e30

Please sign in to comment.