Clap not-exactly positional argument

#1

It should be working, but a command like tipically pm new mysynt panics if I also allow pm new --bin mysynt (and also --lib instead of --bin).

use clap::{App, ArgMatches, Arg, ArgGroup};

pub fn cli<'a, 'b>() -> App<'a, 'b> {
    App::new("new")
        .about("Creates package in a new directory.")
        .arg(Arg::with_name("bin").conflicts_with("bin").required(true))
        .arg(Arg::with_name("lib").conflicts_with("lib").required(true))
        .arg(Arg::from_usage("[NAME]").required(true))
}

pub fn exec<'a, 'b>(matches: &'a ArgMatches<'b>) {
    println!("Brand new [?]");
}

It panics with Found argument '--bin' which wasn't expected, or isn't valid in this context if I execute cargo run -- new --bin halo. With some of the miscellanous tweaks it then complains about positionals requirement missing. I believe astro new halo --bin and astro new --bin halo are both valid or am I misunderstanding positionals?

#2

Weird. Only setting long() stops the matching errors.

    App::new("new")
        .about("Creates package in a new directory.")
        .arg(Arg::with_name("name").required(true).index(1))
        .arg(Arg::with_name("bin").long("bin").conflicts_with("lib"))
        .arg(Arg::with_name("lib").long("lib").conflicts_with("bin"))

Or simply

    App::new("new")
        .about("Creates package in a new directory.")
        .arg(Arg::with_name("name").required(true).index(1))
        .arg(Arg::from_usage("--bin").conflicts_with("lib"))
        .arg(Arg::from_usage("--lib").conflicts_with("bin"))