refactor(examples): Change naming style

This is to make room for a reasonable looking cargo plugin example.

I got lazy and didn't update the tutorials.
This commit is contained in:
Ed Page 2021-12-15 11:12:16 -06:00
parent 1100f04b56
commit 03cb509d6c
17 changed files with 60 additions and 60 deletions

View file

@ -141,29 +141,29 @@ name = "demo"
required-features = ["derive"]
[[example]]
name = "escaped_positional"
name = "escaped-positional"
required-features = ["cargo"]
[[example]]
name = "escaped_positional_derive"
name = "escaped-positional-derive"
required-features = ["derive"]
[[example]]
name = "git_derive"
name = "git-derive"
required-features = ["derive"]
[[example]]
name = "keyvalue_derive"
name = "keyvalue-derive"
required-features = ["derive"]
[[example]]
name = "busybox"
path = "examples/multicall_busybox.rs"
path = "examples/multicall-busybox.rs"
required-features = ["unstable-multicall"]
[[example]]
name = "hostname"
path = "examples/multicall_hostname.rs"
path = "examples/multicall-hostname.rs"
required-features = ["unstable-multicall"]
[[example]]
@ -312,8 +312,8 @@ path = "examples/tutorial_derive/04_04_custom.rs"
required-features = ["derive"]
[[example]]
name = "custom_bool"
path = "examples/derive_ref/custom_bool.rs"
name = "custom-bool"
path = "examples/derive_ref/custom-bool.rs"
required-features = ["derive"]
[profile.test]

View file

@ -1,13 +1,13 @@
# Examples
- Basic demo: [derive](demo.md)
- Key-value pair arguments: [derive](keyvalue_derive.md)
- git-like interface: [builder](git.md), [derive](git_derive.md)
- Key-value pair arguments: [derive](keyvalue-derive.md)
- git-like interface: [builder](git.md), [derive](git-derive.md)
- pacman-like interface: [builder](pacman.md)
- Escaped positionals with `--`: [builder](escaped_positional.md), [derive](escaped_positional_derive.md)
- Escaped positionals with `--`: [builder](escaped-positional.md), [derive](escaped-positional-derive.md)
- Multi-call
- busybox: [builder](multicall_busybox.md)
- hostname: [builder](multicall_hostname.md)
- busybox: [builder](multicall-busybox.md)
- hostname: [builder](multicall-hostname.md)
## Contributing

View file

@ -192,7 +192,7 @@ In addition to the raw attributes, the following magic attributes are supported:
Notes:
- For custom type behavior, you can override the implied attributes/settings and/or set additional ones
- For example, see [custom_bool](./custom_bool.md)
- For example, see [custom-bool](./custom-bool.md)
- `Option<Vec<T>>` will be `None` instead of `vec![]` if no arguments are provided.
- This gives the user some flexibility in designing their argument, like with `min_values(0)`

View file

@ -1,14 +1,14 @@
*Jump to [source](custom_bool.rs)*
*Jump to [source](custom-bool.rs)*
Example of overriding the magic `bool` behavior
```bash
$ custom_bool --help
$ custom-bool --help
clap [..]
A simple to use, efficient, and full-featured Command Line Argument Parser
USAGE:
custom_bool[EXE] [OPTIONS] --foo <FOO> <BOOM>
custom-bool[EXE] [OPTIONS] --foo <FOO> <BOOM>
ARGS:
<BOOM>
@ -18,24 +18,24 @@ OPTIONS:
--foo <FOO>
-h, --help Print help information
-V, --version Print version information
$ custom_bool
$ custom-bool
? failed
error: The following required arguments were not provided:
--foo <FOO>
<BOOM>
USAGE:
custom_bool[EXE] [OPTIONS] --foo <FOO> <BOOM>
custom-bool[EXE] [OPTIONS] --foo <FOO> <BOOM>
For more information try --help
$ custom_bool --foo true false
[examples/derive_ref/custom_bool.rs:31] opt = Opt {
$ custom-bool --foo true false
[examples/derive_ref/custom-bool.rs:31] opt = Opt {
foo: true,
bar: false,
boom: false,
}
$ custom_bool --foo true --bar true false
[examples/derive_ref/custom_bool.rs:31] opt = Opt {
$ custom-bool --foo true --bar true false
[examples/derive_ref/custom-bool.rs:31] opt = Opt {
foo: true,
bar: true,
boom: false,

View file

@ -1,4 +1,4 @@
*Jump to [source](escaped_positional_derive.rs)*
*Jump to [source](escaped-positional-derive.rs)*
**This requires enabling the `derive` feature flag.**
@ -6,12 +6,12 @@ You can use `--` to escape further arguments.
Let's see what this looks like in the help:
```bash
$ escaped_positional_derive --help
$ escaped-positional-derive --help
clap [..]
A simple to use, efficient, and full-featured Command Line Argument Parser
USAGE:
escaped_positional_derive[EXE] [OPTIONS] [-- <SLOP>...]
escaped-positional-derive[EXE] [OPTIONS] [-- <SLOP>...]
ARGS:
<SLOP>...
@ -25,7 +25,7 @@ OPTIONS:
Here is a baseline without any arguments:
```bash
$ escaped_positional_derive
$ escaped-positional-derive
-f used: false
-p's value: None
'slops' values: []
@ -33,19 +33,19 @@ $ escaped_positional_derive
Notice that we can't pass positional arguments before `--`:
```bash
$ escaped_positional_derive foo bar
$ escaped-positional-derive foo bar
? failed
error: Found argument 'foo' which wasn't expected, or isn't valid in this context
USAGE:
escaped_positional_derive[EXE] [OPTIONS] [-- <SLOP>...]
escaped-positional-derive[EXE] [OPTIONS] [-- <SLOP>...]
For more information try --help
```
But you can after:
```bash
$ escaped_positional_derive -f -p=bob -- sloppy slop slop
$ escaped-positional-derive -f -p=bob -- sloppy slop slop
-f used: true
-p's value: Some("bob")
'slops' values: ["sloppy", "slop", "slop"]
@ -53,7 +53,7 @@ $ escaped_positional_derive -f -p=bob -- sloppy slop slop
As mentioned, the parser will directly pass everything through:
```bash
$ escaped_positional_derive -- -f -p=bob sloppy slop slop
$ escaped-positional-derive -- -f -p=bob sloppy slop slop
-f used: false
-p's value: None
'slops' values: ["-f", "-p=bob", "sloppy", "slop", "slop"]

View file

@ -1,4 +1,4 @@
*Jump to [source](escaped_positional.rs)*
*Jump to [source](escaped-positional.rs)*
**This requires enabling the `cargo` feature flag.**
@ -6,12 +6,12 @@ You can use `--` to escape further arguments.
Let's see what this looks like in the help:
```bash
$ escaped_positional --help
$ escaped-positional --help
clap [..]
A simple to use, efficient, and full-featured Command Line Argument Parser
USAGE:
escaped_positional[EXE] [OPTIONS] [-- <SLOP>...]
escaped-positional[EXE] [OPTIONS] [-- <SLOP>...]
ARGS:
<SLOP>...
@ -25,7 +25,7 @@ OPTIONS:
Here is a baseline without any arguments:
```bash
$ escaped_positional
$ escaped-positional
-f used: false
-p's value: None
'slops' values: []
@ -33,19 +33,19 @@ $ escaped_positional
Notice that we can't pass positional arguments before `--`:
```bash
$ escaped_positional foo bar
$ escaped-positional foo bar
? failed
error: Found argument 'foo' which wasn't expected, or isn't valid in this context
USAGE:
escaped_positional[EXE] [OPTIONS] [-- <SLOP>...]
escaped-positional[EXE] [OPTIONS] [-- <SLOP>...]
For more information try --help
```
But you can after:
```bash
$ escaped_positional -f -p=bob -- sloppy slop slop
$ escaped-positional -f -p=bob -- sloppy slop slop
-f used: true
-p's value: Some("bob")
'slops' values: ["sloppy", "slop", "slop"]
@ -53,7 +53,7 @@ $ escaped_positional -f -p=bob -- sloppy slop slop
As mentioned, the parser will directly pass everything through:
```bash
$ escaped_positional -- -f -p=bob sloppy slop slop
$ escaped-positional -- -f -p=bob sloppy slop slop
-f used: false
-p's value: None
'slops' values: ["-f", "-p=bob", "sloppy", "slop", "slop"]

View file

@ -1,4 +1,4 @@
*Jump to [source](git_derive.rs)*
*Jump to [source](git-derive.rs)*
**This requires enabling the `derive` feature flag.**
@ -6,13 +6,13 @@ Git is an example of several common subcommand patterns.
Help:
```bash
$ git_derive
$ git-derive
? failed
git
A fictional versioning CLI
USAGE:
git_derive[EXE] <SUBCOMMAND>
git-derive[EXE] <SUBCOMMAND>
OPTIONS:
-h, --help Print help information
@ -22,12 +22,12 @@ SUBCOMMANDS:
clone Clones repos
help Print this message or the help of the given subcommand(s)
push pushes things
$ git_derive help
$ git-derive help
git
A fictional versioning CLI
USAGE:
git_derive[EXE] <SUBCOMMAND>
git-derive[EXE] <SUBCOMMAND>
OPTIONS:
-h, --help Print help information
@ -37,12 +37,12 @@ SUBCOMMANDS:
clone Clones repos
help Print this message or the help of the given subcommand(s)
push pushes things
$ git_derive help add
git_derive[EXE]-add
$ git-derive help add
git-derive[EXE]-add
adds things
USAGE:
git_derive[EXE] add <PATH>...
git-derive[EXE] add <PATH>...
ARGS:
<PATH>... Stuff to add
@ -53,25 +53,25 @@ OPTIONS:
A basic argument:
```bash
$ git_derive add
$ git-derive add
? failed
git_derive[EXE]-add
git-derive[EXE]-add
adds things
USAGE:
git_derive[EXE] add <PATH>...
git-derive[EXE] add <PATH>...
ARGS:
<PATH>... Stuff to add
OPTIONS:
-h, --help Print help information
$ git_derive add Cargo.toml Cargo.lock
$ git-derive add Cargo.toml Cargo.lock
Adding ["Cargo.toml", "Cargo.lock"]
```
External subcommands:
```bash
$ git_derive custom-tool arg1 --foo bar
$ git-derive custom-tool arg1 --foo bar
Calling out to "custom-tool" with ["arg1", "--foo", "bar"]
```

View file

@ -1,25 +1,25 @@
*Jump to [source](keyvalue_derive.rs)*
*Jump to [source](keyvalue-derive.rs)*
**This requires enabling the `derive` feature flag.**
```bash
$ keyvalue_derive --help
$ keyvalue-derive --help
clap
USAGE:
keyvalue_derive[EXE] [OPTIONS]
keyvalue-derive[EXE] [OPTIONS]
OPTIONS:
-D <DEFINES>
-h, --help Print help information
$ keyvalue_derive -D Foo=10 -D Alice=30
$ keyvalue-derive -D Foo=10 -D Alice=30
Args { defines: [("Foo", 10), ("Alice", 30)] }
$ keyvalue_derive -D Foo
$ keyvalue-derive -D Foo
? failed
error: Invalid value for '-D <DEFINES>': invalid KEY=value: no `=` found in `Foo`
For more information try --help
$ keyvalue_derive -D Foo=Bar
$ keyvalue-derive -D Foo=Bar
? failed
error: Invalid value for '-D <DEFINES>': invalid digit found in string

View file

@ -1,4 +1,4 @@
*Jump to [source](multicall_busybox.rs)*
*Jump to [source](multicall-busybox.rs)*
Example of a busybox-style multicall program

View file

@ -1,4 +1,4 @@
*Jump to [source](multicall_hostname.rs)*
*Jump to [source](multicall-hostname.rs)*
Example of a `hostname-style` multicall program