rust-cookbook
rust-cookbook copied to clipboard
Update chapter 2.1 Clap basic
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.