Skip to content
This repository has been archived by the owner on Sep 14, 2023. It is now read-only.

Strange behavior if subcommand starts with program name #240

Open
markschl opened this issue Aug 14, 2018 · 0 comments
Open

Strange behavior if subcommand starts with program name #240

markschl opened this issue Aug 14, 2018 · 0 comments

Comments

@markschl
Copy link

markschl commented Aug 14, 2018

I'm not sure whether this is expected behavior, but the following seems a bit strange to me:

static USAGE: &'static str = "
Description

Usage:
    prog subcommand <arg>

";

fn main() {
    let d = docopt::Docopt::new(USAGE).unwrap().help(true).parse().unwrap();
    println!("{:?}", d);
}

The above program works fine (cargo run -- subcommand arg). However, if the subcommand is changed to start with the binary name (new usage string: prog progsubcommand <arg> ), running cargo run -- progsubcommand arg will fail with 'Invalid arguments...'. But running cargo run -- subcommand arg will again work. The problem does not occurr on http://try.docopt.org/.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant