summaryrefslogtreecommitdiff
path: root/clap.zig
diff options
context:
space:
mode:
Diffstat (limited to 'clap.zig')
-rw-r--r--clap.zig17
1 files changed, 8 insertions, 9 deletions
diff --git a/clap.zig b/clap.zig
index ac7f6c1..1a6a95d 100644
--- a/clap.zig
+++ b/clap.zig
@@ -5,7 +5,7 @@ const io = std.io;
5const mem = std.mem; 5const mem = std.mem;
6const testing = std.testing; 6const testing = std.testing;
7 7
8pub const args = @import("src/args.zig"); 8pub const args = @import("clap/args.zig");
9 9
10test "clap" { 10test "clap" {
11 _ = args; 11 _ = args;
@@ -13,8 +13,8 @@ test "clap" {
13 _ = StreamingClap; 13 _ = StreamingClap;
14} 14}
15 15
16pub const ComptimeClap = @import("src/comptime.zig").ComptimeClap; 16pub const ComptimeClap = @import("clap/comptime.zig").ComptimeClap;
17pub const StreamingClap = @import("src/streaming.zig").StreamingClap; 17pub const StreamingClap = @import("clap/streaming.zig").StreamingClap;
18 18
19/// The names a ::Param can have. 19/// The names a ::Param can have.
20pub const Names = struct { 20pub const Names = struct {
@@ -69,7 +69,7 @@ pub fn parseParam(line: []const u8) !Param(Help) {
69 if (!mem.startsWith(u8, param_str, "--") and mem.startsWith(u8, param_str, "-")) { 69 if (!mem.startsWith(u8, param_str, "--") and mem.startsWith(u8, param_str, "-")) {
70 const found_comma = param_str[param_str.len - 1] == ','; 70 const found_comma = param_str[param_str.len - 1] == ',';
71 if (found_comma) 71 if (found_comma)
72 param_str = param_str[0..param_str.len - 1]; 72 param_str = param_str[0 .. param_str.len - 1];
73 73
74 if (param_str.len != 2) 74 if (param_str.len != 2)
75 return error.InvalidShortParam; 75 return error.InvalidShortParam;
@@ -83,7 +83,7 @@ pub fn parseParam(line: []const u8) !Param(Help) {
83 const len = mem.indexOfScalar(u8, help_msg[start..], '>') orelse break :blk; 83 const len = mem.indexOfScalar(u8, help_msg[start..], '>') orelse break :blk;
84 res.id.value = help_msg[start..][0..len]; 84 res.id.value = help_msg[start..][0..len];
85 res.takes_value = true; 85 res.takes_value = true;
86 help_msg = help_msg[start + len + 1..]; 86 help_msg = help_msg[start + len + 1 ..];
87 } 87 }
88 } 88 }
89 89
@@ -99,7 +99,7 @@ pub fn parseParam(line: []const u8) !Param(Help) {
99 99
100 if (param_str[param_str.len - 1] == ',') 100 if (param_str[param_str.len - 1] == ',')
101 return error.TrailingComma; 101 return error.TrailingComma;
102 102
103 var help_msg = it.rest(); 103 var help_msg = it.rest();
104 if (it.next()) |next| blk: { 104 if (it.next()) |next| blk: {
105 if (mem.startsWith(u8, next, "<")) { 105 if (mem.startsWith(u8, next, "<")) {
@@ -107,10 +107,10 @@ pub fn parseParam(line: []const u8) !Param(Help) {
107 const len = mem.indexOfScalar(u8, help_msg[start..], '>') orelse break :blk; 107 const len = mem.indexOfScalar(u8, help_msg[start..], '>') orelse break :blk;
108 res.id.value = help_msg[start..][0..len]; 108 res.id.value = help_msg[start..][0..len];
109 res.takes_value = true; 109 res.takes_value = true;
110 help_msg = help_msg[start + len + 1..]; 110 help_msg = help_msg[start + len + 1 ..];
111 } 111 }
112 } 112 }
113 113
114 res.id.msg = mem.trim(u8, help_msg, " \t"); 114 res.id.msg = mem.trim(u8, help_msg, " \t");
115 return res; 115 return res;
116 } 116 }
@@ -223,7 +223,6 @@ fn find(str: []const u8, f: []const u8) []const u8 {
223 return str[i..][0..f.len]; 223 return str[i..][0..f.len];
224} 224}
225 225
226
227/// Will print a help message in the following format: 226/// Will print a help message in the following format:
228/// -s, --long <value_text> help_text 227/// -s, --long <value_text> help_text
229/// -s, help_text 228/// -s, help_text