Skip to content

Commit

Permalink
Merge pull request #3261 from epage/fix-borked-formatting
Browse files Browse the repository at this point in the history
docs: Fix messed up highlighting
  • Loading branch information
epage authored Jan 5, 2022
2 parents a61ad34 + 7110401 commit 2074c56
Show file tree
Hide file tree
Showing 15 changed files with 230 additions and 67 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ criterion = "0.3.2"
trybuild = "1.0.18"
rustversion = "1"
# Cutting out `filesystem` feature
trycmd = { version = "0.8.3", default-features = false, features = ["color-auto", "diff", "examples"] }
trycmd = { version = "0.9", default-features = false, features = ["color-auto", "diff", "examples"] }

[[example]]
name = "demo"
Expand Down
8 changes: 6 additions & 2 deletions examples/cargo-example-derive.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The crate [`clap-cargo`](https://github.com/crate-ci/clap-cargo) can help in
mimicking cargo's interface.

The help looks like:
```bash
```console
$ cargo-example-derive --help
cargo

Expand All @@ -19,6 +19,7 @@ OPTIONS:
SUBCOMMANDS:
example-derive A simple to use, efficient, and full-featured Command Line Argument Parser
help Print this message or the help of the given subcommand(s)

$ cargo-example-derive example-derive --help
cargo-example-derive [..]
A simple to use, efficient, and full-featured Command Line Argument Parser
Expand All @@ -30,12 +31,15 @@ OPTIONS:
-h, --help Print help information
--manifest-path <MANIFEST_PATH>
-V, --version Print version information

```

Then to directly invoke the command, run:
```bash
```console
$ cargo-example-derive example-derive
None

$ cargo-example-derive example-derive --manifest-path Cargo.toml
Some("Cargo.toml")

```
8 changes: 6 additions & 2 deletions examples/cargo-example.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The crate [`clap-cargo`](https://github.com/crate-ci/clap-cargo) can help in
mimicking cargo's interface.

The help looks like:
```bash
```console
$ cargo-example --help
cargo

Expand All @@ -19,6 +19,7 @@ OPTIONS:
SUBCOMMANDS:
example A simple to use, efficient, and full-featured Command Line Argument Parser
help Print this message or the help of the given subcommand(s)

$ cargo-example example --help
cargo-example [..]
A simple to use, efficient, and full-featured Command Line Argument Parser
Expand All @@ -30,12 +31,15 @@ OPTIONS:
-h, --help Print help information
--manifest-path <PATH>
-V, --version Print version information

```

Then to directly invoke the command, run:
```bash
```console
$ cargo-example example
None

$ cargo-example example --manifest-path Cargo.toml
Some("Cargo.toml")

```
3 changes: 2 additions & 1 deletion examples/demo.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
**This requires enabling the `derive` feature flag.**

Used to validate README.md's content
```bash
```console
$ demo --help
clap [..]
A simple to use, efficient, and full-featured Command Line Argument Parser
Expand All @@ -16,4 +16,5 @@ OPTIONS:
-h, --help Print help information
-n, --name <NAME> Name of the person to greet
-V, --version Print version information

```
6 changes: 5 additions & 1 deletion examples/derive_ref/custom-bool.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Example of overriding the magic `bool` behavior

```bash
```console
$ custom-bool --help
clap [..]
A simple to use, efficient, and full-featured Command Line Argument Parser
Expand All @@ -18,6 +18,7 @@ OPTIONS:
--foo <FOO>
-h, --help Print help information
-V, --version Print version information

$ custom-bool
? failed
error: The following required arguments were not provided:
Expand All @@ -28,16 +29,19 @@ USAGE:
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 {
foo: true,
bar: false,
boom: false,
}

$ custom-bool --foo true --bar true false
[examples/derive_ref/custom-bool.rs:31] opt = Opt {
foo: true,
bar: true,
boom: false,
}

```
15 changes: 10 additions & 5 deletions examples/escaped-positional-derive.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
You can use `--` to escape further arguments.

Let's see what this looks like in the help:
```bash
```console
$ escaped-positional-derive --help
clap [..]
A simple to use, efficient, and full-featured Command Line Argument Parser
Expand All @@ -21,18 +21,20 @@ OPTIONS:
-h, --help Print help information
-p <PEAR>
-V, --version Print version information

```

Here is a baseline without any arguments:
```bash
```console
$ escaped-positional-derive
-f used: false
-p's value: None
'slops' values: []

```

Notice that we can't pass positional arguments before `--`:
```bash
```console
$ escaped-positional-derive foo bar
? failed
error: Found argument 'foo' which wasn't expected, or isn't valid in this context
Expand All @@ -41,20 +43,23 @@ USAGE:
escaped-positional-derive[EXE] [OPTIONS] [-- <SLOP>...]

For more information try --help

```

But you can after:
```bash
```console
$ escaped-positional-derive -f -p=bob -- sloppy slop slop
-f used: true
-p's value: Some("bob")
'slops' values: ["sloppy", "slop", "slop"]

```

As mentioned, the parser will directly pass everything through:
```bash
```console
$ escaped-positional-derive -- -f -p=bob sloppy slop slop
-f used: false
-p's value: None
'slops' values: ["-f", "-p=bob", "sloppy", "slop", "slop"]

```
15 changes: 10 additions & 5 deletions examples/escaped-positional.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
You can use `--` to escape further arguments.

Let's see what this looks like in the help:
```bash
```console
$ escaped-positional --help
clap [..]
A simple to use, efficient, and full-featured Command Line Argument Parser
Expand All @@ -21,18 +21,20 @@ OPTIONS:
-h, --help Print help information
-p <PEAR>
-V, --version Print version information

```

Here is a baseline without any arguments:
```bash
```console
$ escaped-positional
-f used: false
-p's value: None
'slops' values: []

```

Notice that we can't pass positional arguments before `--`:
```bash
```console
$ escaped-positional foo bar
? failed
error: Found argument 'foo' which wasn't expected, or isn't valid in this context
Expand All @@ -41,20 +43,23 @@ USAGE:
escaped-positional[EXE] [OPTIONS] [-- <SLOP>...]

For more information try --help

```

But you can after:
```bash
```console
$ escaped-positional -f -p=bob -- sloppy slop slop
-f used: true
-p's value: Some("bob")
'slops' values: ["sloppy", "slop", "slop"]

```

As mentioned, the parser will directly pass everything through:
```bash
```console
$ escaped-positional -- -f -p=bob sloppy slop slop
-f used: false
-p's value: None
'slops' values: ["-f", "-p=bob", "sloppy", "slop", "slop"]

```
12 changes: 9 additions & 3 deletions examples/git-derive.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Git is an example of several common subcommand patterns.

Help:
```bash
```console
$ git-derive
? failed
git
Expand All @@ -22,6 +22,7 @@ SUBCOMMANDS:
clone Clones repos
help Print this message or the help of the given subcommand(s)
push pushes things

$ git-derive help
git
A fictional versioning CLI
Expand All @@ -37,6 +38,7 @@ 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
adds things
Expand All @@ -49,10 +51,11 @@ ARGS:

OPTIONS:
-h, --help Print help information

```

A basic argument:
```bash
```console
$ git-derive add
? failed
git-derive[EXE]-add
Expand All @@ -66,12 +69,15 @@ ARGS:

OPTIONS:
-h, --help Print help information

$ git-derive add Cargo.toml Cargo.lock
Adding ["Cargo.toml", "Cargo.lock"]

```

External subcommands:
```bash
```console
$ git-derive custom-tool arg1 --foo bar
Calling out to "custom-tool" with ["arg1", "--foo", "bar"]

```
12 changes: 9 additions & 3 deletions examples/git.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Git is an example of several common subcommand patterns.

Help:
```bash
```console
$ git
? failed
git
Expand All @@ -20,6 +20,7 @@ SUBCOMMANDS:
clone Clones repos
help Print this message or the help of the given subcommand(s)
push pushes things

$ git help
git
A fictional versioning CLI
Expand All @@ -35,6 +36,7 @@ SUBCOMMANDS:
clone Clones repos
help Print this message or the help of the given subcommand(s)
push pushes things

$ git help add
git[EXE]-add
adds things
Expand All @@ -47,10 +49,11 @@ ARGS:

OPTIONS:
-h, --help Print help information

```

A basic argument:
```bash
```console
$ git add
? failed
git[EXE]-add
Expand All @@ -64,12 +67,15 @@ ARGS:

OPTIONS:
-h, --help Print help information

$ git add Cargo.toml Cargo.lock
Adding ["Cargo.toml", "Cargo.lock"]

```

External subcommands:
```bash
```console
$ git custom-tool arg1 --foo bar
Calling out to "custom-tool" with ["arg1", "--foo", "bar"]

```
6 changes: 5 additions & 1 deletion examples/keyvalue-derive.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

**This requires enabling the `derive` feature flag.**

```bash
```console
$ keyvalue-derive --help
clap

Expand All @@ -12,16 +12,20 @@ USAGE:
OPTIONS:
-D <DEFINES>
-h, --help Print help information

$ keyvalue-derive -D Foo=10 -D Alice=30
Args { defines: [("Foo", 10), ("Alice", 30)] }

$ 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
? failed
error: Invalid value for '-D <DEFINES>': invalid digit found in string

For more information try --help

```
Loading

0 comments on commit 2074c56

Please sign in to comment.