[][src]Macro clap::load_yaml

macro_rules! load_yaml {
    ($yml:expr) => { ... };

A convenience macro for loading the YAML file at compile time (relative to the current file, like modules work). That YAML object can then be passed to this function.


The YAML file must be properly formatted or this function will panic!(). A good way to ensure this doesn't happen is to run your program with the --help switch. If this passes without error, you needn't worry because the YAML is properly formatted.


The following example shows how to load a properly formatted YAML file to build an instance of an App struct.

This example is not tested
let yml = load_yaml!("app.yml");
let app = App::from_yaml(yml);

// continued logic goes here, such as `app.get_matches()` etc.