Skip to content

Commit

Permalink
examples(17_yaml): conditinonally compile 17_yaml example
Browse files Browse the repository at this point in the history
  • Loading branch information
sru committed Dec 9, 2015
1 parent 82f9845 commit 575de08
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion examples/17_yaml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ extern crate clap;

use clap::App;

#[cfg(feature = "yaml")]
fn main() {
// To load a yaml file containing our CLI definition such as the example '17_yaml.yml' we can
// use the convenience macro which loads the file at compile relative to the current file
Expand All @@ -42,4 +43,11 @@ fn main() {
} else {
println!("--mode <MODE> wasn't used...");
}
}
}

#[cfg(not(feature = "yaml"))]
fn main() {
// As stated above, if clap is not compiled with the YAML feature, it is disabled.
println!("YAML feature is disabled.");
println!("Pass --features yaml to cargo when trying this example.");
}

0 comments on commit 575de08

Please sign in to comment.