From 9de3cd86063d9476be0b7690d69c20f315d271b0 Mon Sep 17 00:00:00 2001 From: Jimmi Holst Christensen Date: Thu, 24 Oct 2024 17:40:56 +0200 Subject: docs: Add subcommand example --- example/README.md.template | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'example/README.md.template') 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 for each none positional parameter of your program. The name of the field will be the longest name of the parameter. `positionals` be a tuple with one field for each positional parameter. -The fields in `args` and `psotionals` are typed. The type is based on the name of the value the +The fields in `args` and `postionals` are typed. The type is based on the name of the value the parameter takes. Since `--number` takes a `usize` the field `res.args.number` has the type `usize`. 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 {s} ``` +### Subcommands + +There is an option for `clap.parse` and `clap.parseEx` called `terminating_positional`. It allows +for users of `clap` to implement subcommands in their cli application: + +```zig +{s} +``` + ### `streaming.Clap` The `streaming.Clap` is the base of all the other parsers. It's a streaming parser that uses an -- cgit v1.2.3