diff options
Diffstat (limited to 'example/README.md.template')
| -rw-r--r-- | example/README.md.template | 51 |
1 files changed, 17 insertions, 34 deletions
diff --git a/example/README.md.template b/example/README.md.template index 7f5c545..9fbc1cc 100644 --- a/example/README.md.template +++ b/example/README.md.template | |||
| @@ -27,33 +27,24 @@ The simplest way to use this library is to just call the `clap.parse` function. | |||
| 27 | {s} | 27 | {s} |
| 28 | ``` | 28 | ``` |
| 29 | 29 | ||
| 30 | The data structure returned has lookup speed on par with array access (`arr[i]`) and validates | 30 | The result will contain an `args` field and a `positionals` field. `args` will have one field |
| 31 | that the strings you pass to `option`, `options` and `flag` are actually parameters that the | 31 | for each none positional parameter of your program. The name of the field will be the longest |
| 32 | program can take: | 32 | name of the parameter. |
| 33 | |||
| 34 | The fields in `args` are typed. The type is based on the name of the value the parameter takes. | ||
| 35 | Since `--number` takes a `usize` the field `res.args.number` has the type `usize`. | ||
| 36 | |||
| 37 | Note that this is only the case because `clap.parsers.default` has a field called `usize` which | ||
| 38 | contains a parser that returns `usize`. You can pass in something other than `clap.parsers.default` | ||
| 39 | if you want some other mapping. | ||
| 33 | 40 | ||
| 34 | ```zig | 41 | ```zig |
| 35 | {s} | 42 | {s} |
| 36 | ``` | 43 | ``` |
| 37 | 44 | ||
| 38 | ``` | 45 | ### `streaming.Clap` |
| 39 | zig-clap/clap/comptime.zig:109:17: error: --helps is not a parameter. | ||
| 40 | @compileError(name ++ " is not a parameter."); | ||
| 41 | ^ | ||
| 42 | zig-clap/clap/comptime.zig:77:45: note: called from here | ||
| 43 | const param = comptime findParam(name); | ||
| 44 | ^ | ||
| 45 | zig-clap/clap.zig:238:31: note: called from here | ||
| 46 | return a.clap.flag(name); | ||
| 47 | ^ | ||
| 48 | zig-clap/example/simple-error.zig:16:18: note: called from here | ||
| 49 | _ = args.flag("--helps"); | ||
| 50 | ``` | ||
| 51 | |||
| 52 | There is also a `parseEx` variant that takes an argument iterator. | ||
| 53 | 46 | ||
| 54 | ### `StreamingClap` | 47 | The `streaming.Clap` is the base of all the other parsers. It's a streaming parser that uses an |
| 55 | |||
| 56 | The `StreamingClap` is the base of all the other parsers. It's a streaming parser that uses an | ||
| 57 | `args.Iterator` to provide it with arguments lazily. | 48 | `args.Iterator` to provide it with arguments lazily. |
| 58 | 49 | ||
| 59 | ```zig | 50 | ```zig |
| @@ -65,8 +56,9 @@ is generated at runtime. | |||
| 65 | 56 | ||
| 66 | ### `help` | 57 | ### `help` |
| 67 | 58 | ||
| 68 | The `help`, `helpEx` and `helpFull` are functions for printing a simple list of all parameters the | 59 | The `help` prints a simple list of all parameters the program can take. It expects the |
| 69 | program can take. | 60 | `Id` to have a `description` method and an `value` method so that it can provide that |
| 61 | in the output. | ||
| 70 | 62 | ||
| 71 | ```zig | 63 | ```zig |
| 72 | {s} | 64 | {s} |
| @@ -78,19 +70,10 @@ $ zig-out/bin/help --help | |||
| 78 | -v, --version Output version information and exit. | 70 | -v, --version Output version information and exit. |
| 79 | ``` | 71 | ``` |
| 80 | 72 | ||
| 81 | The `help` functions are the simplest to call. It only takes an `OutStream` and a slice of | ||
| 82 | `Param(Help)`. | ||
| 83 | |||
| 84 | The `helpEx` is the generic version of `help`. It can print a help message for any | ||
| 85 | `Param` give that the caller provides functions for getting the help and value strings. | ||
| 86 | |||
| 87 | The `helpFull` is even more generic, allowing the functions that get the help and value strings | ||
| 88 | to return errors and take a context as a parameter. | ||
| 89 | |||
| 90 | ### `usage` | 73 | ### `usage` |
| 91 | 74 | ||
| 92 | The `usage`, `usageEx` and `usageFull` are functions for printing a small abbreviated version | 75 | The `usage` prints a small abbreviated version of the help message. It expects the `Id` |
| 93 | of the help message. | 76 | to have a `value` method so it can provide that in the output. |
| 94 | 77 | ||
| 95 | ```zig | 78 | ```zig |
| 96 | {s} | 79 | {s} |