diff options
| -rw-r--r-- | README.md | 4 | ||||
| -rw-r--r-- | clap.zig | 18 | ||||
| -rw-r--r-- | example/simple.zig | 2 | ||||
| -rw-r--r-- | example/streaming-clap.zig | 2 |
4 files changed, 13 insertions, 13 deletions
| @@ -46,7 +46,7 @@ pub fn main() !void { | |||
| 46 | \\ | 46 | \\ |
| 47 | ); | 47 | ); |
| 48 | 48 | ||
| 49 | // Initalize our diagnostics, which can be used for reporting useful errors. | 49 | // Initialize our diagnostics, which can be used for reporting useful errors. |
| 50 | // This is optional. You can also pass `.{}` to `clap.parse` if you don't | 50 | // This is optional. You can also pass `.{}` to `clap.parse` if you don't |
| 51 | // care about the extra information `Diagnostics` provides. | 51 | // care about the extra information `Diagnostics` provides. |
| 52 | var diag = clap.Diagnostic{}; | 52 | var diag = clap.Diagnostic{}; |
| @@ -171,7 +171,7 @@ pub fn main() !void { | |||
| 171 | // Skip exe argument | 171 | // Skip exe argument |
| 172 | _ = iter.next(); | 172 | _ = iter.next(); |
| 173 | 173 | ||
| 174 | // Initalize our diagnostics, which can be used for reporting useful errors. | 174 | // Initialize our diagnostics, which can be used for reporting useful errors. |
| 175 | // This is optional. You can also leave the `diagnostic` field unset if you | 175 | // This is optional. You can also leave the `diagnostic` field unset if you |
| 176 | // don't care about the extra information `Diagnostic` provides. | 176 | // don't care about the extra information `Diagnostic` provides. |
| 177 | var diag = clap.Diagnostic{}; | 177 | var diag = clap.Diagnostic{}; |
| @@ -79,7 +79,7 @@ pub const Values = enum { | |||
| 79 | /// * "-abc=value" | 79 | /// * "-abc=value" |
| 80 | /// * "-abcvalue" | 80 | /// * "-abcvalue" |
| 81 | /// * Long ("--long-param"): Should be used for less common parameters, or when no single | 81 | /// * Long ("--long-param"): Should be used for less common parameters, or when no single |
| 82 | /// character can describe the paramter. | 82 | /// character can describe the parameter. |
| 83 | /// * They can take a value two different ways. | 83 | /// * They can take a value two different ways. |
| 84 | /// * "--long-param value" | 84 | /// * "--long-param value" |
| 85 | /// * "--long-param=value" | 85 | /// * "--long-param=value" |
| @@ -722,7 +722,7 @@ pub fn Result( | |||
| 722 | /// `T` can be any type and `Error` can be any error. You can pass `clap.parsers.default` if you | 722 | /// `T` can be any type and `Error` can be any error. You can pass `clap.parsers.default` if you |
| 723 | /// just wonna get something up and running. | 723 | /// just wonna get something up and running. |
| 724 | /// | 724 | /// |
| 725 | /// Caller ownes the result and should free it by calling `result.deinit()` | 725 | /// Caller owns the result and should free it by calling `result.deinit()` |
| 726 | pub fn parseEx( | 726 | pub fn parseEx( |
| 727 | comptime Id: type, | 727 | comptime Id: type, |
| 728 | comptime params: []const Param(Id), | 728 | comptime params: []const Param(Id), |
| @@ -744,7 +744,7 @@ pub fn parseEx( | |||
| 744 | }; | 744 | }; |
| 745 | while (try stream.next()) |arg| { | 745 | while (try stream.next()) |arg| { |
| 746 | // TODO: We cannot use `try` inside the inline for because of a compiler bug that | 746 | // TODO: We cannot use `try` inside the inline for because of a compiler bug that |
| 747 | // generates an infinit loop. For now, use a variable to store the error | 747 | // generates an infinite loop. For now, use a variable to store the error |
| 748 | // and use `try` outside. The downside of this is that we have to use | 748 | // and use `try` outside. The downside of this is that we have to use |
| 749 | // `anyerror` :( | 749 | // `anyerror` :( |
| 750 | var res: anyerror!void = {}; | 750 | var res: anyerror!void = {}; |
| @@ -895,7 +895,7 @@ const MultiArgKind = enum { slice, list }; | |||
| 895 | 895 | ||
| 896 | /// Turn a list of parameters into a struct with one field for each none positional parameter. | 896 | /// Turn a list of parameters into a struct with one field for each none positional parameter. |
| 897 | /// The type of each parameter field is determined by `ParamType`. Positional arguments will not | 897 | /// The type of each parameter field is determined by `ParamType`. Positional arguments will not |
| 898 | /// havea field in this struct. | 898 | /// have a field in this struct. |
| 899 | fn Arguments( | 899 | fn Arguments( |
| 900 | comptime Id: type, | 900 | comptime Id: type, |
| 901 | comptime params: []const Param(Id), | 901 | comptime params: []const Param(Id), |
| @@ -1045,11 +1045,11 @@ pub const Help = struct { | |||
| 1045 | 1045 | ||
| 1046 | pub const HelpOptions = struct { | 1046 | pub const HelpOptions = struct { |
| 1047 | /// Render the description of a parameter in a simular way to how markdown would render | 1047 | /// Render the description of a parameter in a simular way to how markdown would render |
| 1048 | /// such a string. This means that single newlines wont be respected unless followed by | 1048 | /// such a string. This means that single newlines won't be respected unless followed by |
| 1049 | /// bullet points or other markdown elements. | 1049 | /// bullet points or other markdown elements. |
| 1050 | markdown_lite: bool = true, | 1050 | markdown_lite: bool = true, |
| 1051 | 1051 | ||
| 1052 | /// Wether `help` should print the description of a parameter on a new line instead of after | 1052 | /// Whether `help` should print the description of a parameter on a new line instead of after |
| 1053 | /// the parameter names. This options works together with `description_indent` to change | 1053 | /// the parameter names. This options works together with `description_indent` to change |
| 1054 | /// where descriptions are printed. | 1054 | /// where descriptions are printed. |
| 1055 | /// | 1055 | /// |
| @@ -1071,7 +1071,7 @@ pub const HelpOptions = struct { | |||
| 1071 | /// changes the output. | 1071 | /// changes the output. |
| 1072 | description_indent: usize = 8, | 1072 | description_indent: usize = 8, |
| 1073 | 1073 | ||
| 1074 | /// How much to indent each paramter. | 1074 | /// How much to indent each parameter. |
| 1075 | /// | 1075 | /// |
| 1076 | /// indent=0, description_on_new_line=false, description_indent=4 | 1076 | /// indent=0, description_on_new_line=false, description_indent=4 |
| 1077 | /// | 1077 | /// |
| @@ -1088,7 +1088,7 @@ pub const HelpOptions = struct { | |||
| 1088 | indent: usize = 4, | 1088 | indent: usize = 4, |
| 1089 | 1089 | ||
| 1090 | /// The maximum width of the help message. `help` will try to break the description of | 1090 | /// The maximum width of the help message. `help` will try to break the description of |
| 1091 | /// paramters into multiple lines if they exeed this maximum. Setting this to the width | 1091 | /// parameters into multiple lines if they exceed this maximum. Setting this to the width |
| 1092 | /// of the terminal is a nice way of using this option. | 1092 | /// of the terminal is a nice way of using this option. |
| 1093 | max_width: usize = std.math.maxInt(usize), | 1093 | max_width: usize = std.math.maxInt(usize), |
| 1094 | 1094 | ||
| @@ -1722,7 +1722,7 @@ pub fn usage(stream: anytype, comptime Id: type, params: []const Param(Id)) !voi | |||
| 1722 | 1722 | ||
| 1723 | const prefix = if (param.names.short) |_| "-" else "--"; | 1723 | const prefix = if (param.names.short) |_| "-" else "--"; |
| 1724 | const name = if (param.names.short) |*s| | 1724 | const name = if (param.names.short) |*s| |
| 1725 | // Seems the zig compiler is being a little wierd. I doesn't allow me to write | 1725 | // Seems the zig compiler is being a little weird. I doesn't allow me to write |
| 1726 | // @as(*const [1]u8, s) | 1726 | // @as(*const [1]u8, s) |
| 1727 | @ptrCast([*]const u8, s)[0..1] | 1727 | @ptrCast([*]const u8, s)[0..1] |
| 1728 | else | 1728 | else |
diff --git a/example/simple.zig b/example/simple.zig index 1ac7de5..2d32463 100644 --- a/example/simple.zig +++ b/example/simple.zig | |||
| @@ -15,7 +15,7 @@ pub fn main() !void { | |||
| 15 | \\ | 15 | \\ |
| 16 | ); | 16 | ); |
| 17 | 17 | ||
| 18 | // Initalize our diagnostics, which can be used for reporting useful errors. | 18 | // Initialize our diagnostics, which can be used for reporting useful errors. |
| 19 | // This is optional. You can also pass `.{}` to `clap.parse` if you don't | 19 | // This is optional. You can also pass `.{}` to `clap.parse` if you don't |
| 20 | // care about the extra information `Diagnostics` provides. | 20 | // care about the extra information `Diagnostics` provides. |
| 21 | var diag = clap.Diagnostic{}; | 21 | var diag = clap.Diagnostic{}; |
diff --git a/example/streaming-clap.zig b/example/streaming-clap.zig index cacda56..9d99859 100644 --- a/example/streaming-clap.zig +++ b/example/streaming-clap.zig | |||
| @@ -28,7 +28,7 @@ pub fn main() !void { | |||
| 28 | // Skip exe argument | 28 | // Skip exe argument |
| 29 | _ = iter.next(); | 29 | _ = iter.next(); |
| 30 | 30 | ||
| 31 | // Initalize our diagnostics, which can be used for reporting useful errors. | 31 | // Initialize our diagnostics, which can be used for reporting useful errors. |
| 32 | // This is optional. You can also leave the `diagnostic` field unset if you | 32 | // This is optional. You can also leave the `diagnostic` field unset if you |
| 33 | // don't care about the extra information `Diagnostic` provides. | 33 | // don't care about the extra information `Diagnostic` provides. |
| 34 | var diag = clap.Diagnostic{}; | 34 | var diag = clap.Diagnostic{}; |