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

Strange behavior if subcommand starts with program name #240

@markschl

Description

@markschl

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/.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions