summaryrefslogtreecommitdiffstats
path: root/vendor/clap/examples/cargo-example.md
blob: edf8ee18a31b290ec9a0e9450efc0c7e80c276ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
For more on creating a custom subcommand, see [the cargo
book](https://doc.rust-lang.org/cargo/reference/external-tools.html#custom-subcommands).
The crate [`clap-cargo`](https://github.com/crate-ci/clap-cargo) can help in
mimicking cargo's interface.

The help looks like:
```console
$ cargo-example --help
Usage: cargo <COMMAND>

Commands:
  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)

Options:
  -h, --help  Print help

$ cargo-example example --help
A simple to use, efficient, and full-featured Command Line Argument Parser

Usage: cargo example [OPTIONS]

Options:
      --manifest-path <PATH>  
  -h, --help                  Print help
  -V, --version               Print version

```

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

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

```