diff options
| author | 2024-10-24 17:40:56 +0200 | |
|---|---|---|
| committer | 2024-10-24 17:45:01 +0200 | |
| commit | 281090c23ca631d8811d7ccb2a0dcdf4ef72a7b1 (patch) | |
| tree | 0faafb2b82ddd85ddc824332310be23660c5867c /example/README.md.template | |
| parent | feat: Support multiple positionals of different types (diff) | |
| download | zig-clap-281090c23ca631d8811d7ccb2a0dcdf4ef72a7b1.tar.gz zig-clap-281090c23ca631d8811d7ccb2a0dcdf4ef72a7b1.tar.xz zig-clap-281090c23ca631d8811d7ccb2a0dcdf4ef72a7b1.zip | |
docs: Add subcommand example
Diffstat (limited to 'example/README.md.template')
| -rw-r--r-- | example/README.md.template | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/example/README.md.template b/example/README.md.template index d234dcd..bcd3774 100644 --- a/example/README.md.template +++ b/example/README.md.template | |||
| @@ -63,7 +63,7 @@ The result will contain an `args` field and a `positionals` field. `args` will h | |||
| 63 | for each none positional parameter of your program. The name of the field will be the longest | 63 | for each none positional parameter of your program. The name of the field will be the longest |
| 64 | name of the parameter. `positionals` be a tuple with one field for each positional parameter. | 64 | name of the parameter. `positionals` be a tuple with one field for each positional parameter. |
| 65 | 65 | ||
| 66 | The fields in `args` and `psotionals` are typed. The type is based on the name of the value the | 66 | The fields in `args` and `postionals` are typed. The type is based on the name of the value the |
| 67 | parameter takes. Since `--number` takes a `usize` the field `res.args.number` has the type `usize`. | 67 | parameter takes. Since `--number` takes a `usize` the field `res.args.number` has the type `usize`. |
| 68 | 68 | ||
| 69 | Note that this is only the case because `clap.parsers.default` has a field called `usize` which | 69 | Note that this is only the case because `clap.parsers.default` has a field called `usize` which |
| @@ -74,6 +74,15 @@ contains a parser that returns `usize`. You can pass in something other than | |||
| 74 | {s} | 74 | {s} |
| 75 | ``` | 75 | ``` |
| 76 | 76 | ||
| 77 | ### Subcommands | ||
| 78 | |||
| 79 | There is an option for `clap.parse` and `clap.parseEx` called `terminating_positional`. It allows | ||
| 80 | for users of `clap` to implement subcommands in their cli application: | ||
| 81 | |||
| 82 | ```zig | ||
| 83 | {s} | ||
| 84 | ``` | ||
| 85 | |||
| 77 | ### `streaming.Clap` | 86 | ### `streaming.Clap` |
| 78 | 87 | ||
| 79 | The `streaming.Clap` is the base of all the other parsers. It's a streaming parser that uses an | 88 | The `streaming.Clap` is the base of all the other parsers. It's a streaming parser that uses an |