diff --git a/examples/typed-derive.md b/examples/typed-derive.md index ae93d23f..d6e0f96e 100644 --- a/examples/typed-derive.md +++ b/examples/typed-derive.md @@ -13,6 +13,7 @@ USAGE: OPTIONS: -D Hand-written parser for tuples -h, --help Print help information + -I Allow invalid UTF-8 paths -O Implicitly using `std::str::FromStr` ``` @@ -20,7 +21,7 @@ OPTIONS: Optimization-level (number) ```console $ typed-derive -O 1 -Args { optimization: Some(1), defines: [] } +Args { optimization: Some(1), include: None, defines: [] } $ typed-derive -O plaid ? failed @@ -30,10 +31,17 @@ For more information try --help ``` +Include (path) +```console +$ typed-derive -I../hello +Args { optimization: None, include: Some("../hello"), defines: [] } + +``` + Defines (key-value pairs) ```console $ typed-derive -D Foo=10 -D Alice=30 -Args { optimization: None, defines: [("Foo", 10), ("Alice", 30)] } +Args { optimization: None, include: None, defines: [("Foo", 10), ("Alice", 30)] } $ typed-derive -D Foo ? failed diff --git a/examples/typed-derive.rs b/examples/typed-derive.rs index ba69abe9..3e5563e3 100644 --- a/examples/typed-derive.rs +++ b/examples/typed-derive.rs @@ -9,6 +9,10 @@ struct Args { #[clap(short = 'O')] optimization: Option, + /// Allow invalid UTF-8 paths + #[clap(short = 'I', parse(from_os_str), value_name = "DIR", value_hint = clap::ValueHint::DirPath)] + include: Option, + /// Hand-written parser for tuples #[clap(short = 'D', parse(try_from_str = parse_key_val), multiple_occurrences(true))] defines: Vec<(String, i32)>,