rust-cookbook icon indicating copy to clipboard operation
rust-cookbook copied to clipboard

Update chapter 2.1 Clap basic

Open c12i opened this issue 5 years ago • 0 comments
trafficstars

The current code example will not compile if you use the clap v3.0.0-beta.2, the version indicated above it. In this version of clap, the Arg struct no longer has the with_name or the help methods. Instead, use the new and about methods respectively:

//...
let matches = App::new("My Test Program")
        .version("0.1.0")
        .author("Collins Muriuki <[email protected]>")
        .about("Teaches argument parsing")
        .arg(Arg::new("file")
            .short('f')
            .long("file")
            .takes_value(true)
            .about("A cool file"))
//...

Also, the newer short method now accepts a char type rather than &str as a parameter.

c12i avatar Sep 26 '20 23:09 c12i