docopt parsing is too lenient with optional params
reported issue: https://github.com/paritytech/ethabi/issues/40 related #219
external repo with tests: https://github.com/debris/docopt_bug/blob/master/src/lib.rs
tests from external repo run with docopt 0.8.1
running 7 tests
test test_short ... FAILED
test test_short_with_three_params ... FAILED
test test_short_with_one_param ... FAILED
test test_short_with_two_params ... ok
test test_two_shorts_with_three_params ... FAILED
test test_short_with_four_params ... FAILED
test test_two_shorts_with_four_params ... ok
I think I've run into a related issue in cargo-edit. Our usage string is:
Usage:
cargo add <crate> [--dev|--build|--optional] [--vers=<ver>|--git=<uri>|--path=<uri>] [options]
cargo add <crates>... [--dev|--build|--optional] [options]
cargo add (-h|--help)
cargo add --version
Specify what crate to add:
--vers <ver> Specify the version to grab from the registry (crates.io).
You can also specify versions as part of the name, e.g
`cargo add [email protected]`.
--git <uri> Specify a git repository to download the crate from.
--path <uri> Specify the path the crate should be loaded from.
Specify where to add the crate:
-D --dev Add crate as development dependency.
-B --build Add crate as build dependency.
--optional Add as an optional dependency (for use in features). This does not work
for `dev-dependencies` or `build-dependencies`.
--target <target> Add as dependency to the given target platform. This does not work
for `dev-dependencies` or `build-dependencies`.
Options:
--upgrade=<method> Choose method of semantic version upgrade. Must be one of
"none" (exact version), "patch" (`~` modifier), "minor"
(`^` modifier, default), or "all" (`>=`).
--manifest-path=<path> Path to the manifest to add a dependency to.
--allow-prerelease Include prerelease versions when fetching from crates.io (e.g.
'0.6.0-alpha'). Defaults to false.
-h --help Show this help page.
-V --version Show version.
This command allows you to add a dependency to a Cargo.toml manifest file. If <crate> is a github
or gitlab repository URL, or a local path, `cargo add` will try to automatically get the crate name
and set the appropriate `--git` or `--path` value.
Please note that Cargo treats versions like "1.2.3" as "^1.2.3" (and that "^1.2.3" is specified
as ">=1.2.3 and <2.0.0"). By default, `cargo add` will use this format, as it is the one that the
crates.io registry suggests. One goal of `cargo add` is to prevent you from using wildcard
dependencies (version set to "*").
and the command cargo add failure --vers 0.4.3 --git git://git.git --path /path/here results in the output Args { arg_crate: "", arg_crates: ["failure"], flag_dev: false, flag_build: false, flag_vers: Some("0.4.3"), flag_git: Some("git://git.git"), flag_path: Some("/path/here"), flag_target: None, flag_optional: false, flag_manifest_path: None, flag_version: false, flag_upgrade: None, flag_allow_prerelease: false }.
I believe that that command should be rejected as invalid (as http://try.docopt.org does).
See https://github.com/killercup/cargo-edit/issues/174 for more information