Skip to content

Commit 575de08

Browse files
committed
examples(17_yaml): conditinonally compile 17_yaml example
1 parent 82f9845 commit 575de08

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

examples/17_yaml.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ extern crate clap;
1919

2020
use clap::App;
2121

22+
#[cfg(feature = "yaml")]
2223
fn main() {
2324
// To load a yaml file containing our CLI definition such as the example '17_yaml.yml' we can
2425
// use the convenience macro which loads the file at compile relative to the current file
@@ -42,4 +43,11 @@ fn main() {
4243
} else {
4344
println!("--mode <MODE> wasn't used...");
4445
}
45-
}
46+
}
47+
48+
#[cfg(not(feature = "yaml"))]
49+
fn main() {
50+
// As stated above, if clap is not compiled with the YAML feature, it is disabled.
51+
println!("YAML feature is disabled.");
52+
println!("Pass --features yaml to cargo when trying this example.");
53+
}

0 commit comments

Comments
 (0)