Cargo.toml:
[dependencies]
clap = { git = "https://github.com/kbknapp/clap-rs.git" }
Simple main.rs:
#[macro_use] extern crate clap;
use clap::App;
fn main() {
let yml = load_yaml!("cli.yml");
let matches = App::from_yaml(yml).get_matches();
}
And cargo build produces: src/main.rs:11:15: 11:24 error: macro undefined: 'load_yaml!
Using the regular, code-based App construction works, only I can't get the YAML loading feature to work.
Thank you for your report!
To use YAML feature you need to specify it in Cargo.toml. You can do it in two ways:
[dependencies.clap]
features = ["yaml"]
or
[dependencies]
clap = { features = ["yaml"] }
Take a look at yaml example
If you will have further questions, or this advice willn't help you - let us know!
Many thanks! Sorry for opening a ticket then: looks like my noobness with regards to Rust was the problem then :)
Also, thanks for a great library, a good option parser is really a boon to have!
No problem!
If you will have futher questions - feel free to ask them. You can use our gitter channel for it.
@Vinatorul @milgner How did you manage to run this code? When i do cargo run --features yaml with cargo.toml looking like in this
[dependencies]
clap = { features = ["yaml"] }
or
[dependencies.clap]
features = ["yaml"]
i get error
:!cargo run --features yaml
error: Package `fun v0.1.0 (/Users/XXX/Projekty/rust/fun)` does not have these fe
atures: `yaml`
shell returned 101
You have to do just cargo run.