mirror of
https://github.com/clap-rs/clap
synced 2024-12-12 13:52:34 +00:00
docs(examples): Allow any path
This commit is contained in:
parent
ce9e2cba8f
commit
c230c72120
2 changed files with 14 additions and 2 deletions
|
@ -13,6 +13,7 @@ USAGE:
|
|||
OPTIONS:
|
||||
-D <DEFINES> Hand-written parser for tuples
|
||||
-h, --help Print help information
|
||||
-I <DIR> Allow invalid UTF-8 paths
|
||||
-O <OPTIMIZATION> 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
|
||||
|
|
|
@ -9,6 +9,10 @@ struct Args {
|
|||
#[clap(short = 'O')]
|
||||
optimization: Option<usize>,
|
||||
|
||||
/// Allow invalid UTF-8 paths
|
||||
#[clap(short = 'I', parse(from_os_str), value_name = "DIR", value_hint = clap::ValueHint::DirPath)]
|
||||
include: Option<std::path::PathBuf>,
|
||||
|
||||
/// Hand-written parser for tuples
|
||||
#[clap(short = 'D', parse(try_from_str = parse_key_val), multiple_occurrences(true))]
|
||||
defines: Vec<(String, i32)>,
|
||||
|
|
Loading…
Reference in a new issue