summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jimmi Holst Christensen2019-10-06 17:20:56 +0200
committerGravatar Jimmi Holst Christensen2019-10-06 17:20:56 +0200
commitf3eb797336c1bbdae391657ef6ac54e4015b5fde (patch)
tree0f99b8a43adddcadca24a2ec0b47b779ef923904
parentDelete download-zig.sh (diff)
downloadzig-clap-f3eb797336c1bbdae391657ef6ac54e4015b5fde.tar.gz
zig-clap-f3eb797336c1bbdae391657ef6ac54e4015b5fde.tar.xz
zig-clap-f3eb797336c1bbdae391657ef6ac54e4015b5fde.zip
fmt, mv src/ clap/ and run fmt on build
-rw-r--r--build.zig5
-rw-r--r--clap.zig17
-rw-r--r--clap/args.zig (renamed from src/args.zig)0
-rw-r--r--clap/comptime.zig (renamed from src/comptime.zig)0
-rw-r--r--clap/streaming.zig (renamed from src/streaming.zig)2
5 files changed, 14 insertions, 10 deletions
diff --git a/build.zig b/build.zig
index 104e7e3..9d2ef7b 100644
--- a/build.zig
+++ b/build.zig
@@ -7,6 +7,11 @@ const Builder = std.build.Builder;
7pub fn build(b: *Builder) void { 7pub fn build(b: *Builder) void {
8 const mode = b.standardReleaseOptions(); 8 const mode = b.standardReleaseOptions();
9 9
10 const fmt_step = b.addFmt([_][]const u8{
11 "build.zig",
12 "clap",
13 });
14
10 const test_all_step = b.step("test", "Run all tests in all modes."); 15 const test_all_step = b.step("test", "Run all tests in all modes.");
11 inline for ([_]Mode{ Mode.Debug, Mode.ReleaseFast, Mode.ReleaseSafe, Mode.ReleaseSmall }) |test_mode| { 16 inline for ([_]Mode{ Mode.Debug, Mode.ReleaseFast, Mode.ReleaseSafe, Mode.ReleaseSmall }) |test_mode| {
12 const mode_str = comptime modeToString(test_mode); 17 const mode_str = comptime modeToString(test_mode);
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
diff --git a/src/args.zig b/clap/args.zig
index 4234ada..4234ada 100644
--- a/src/args.zig
+++ b/clap/args.zig
diff --git a/src/comptime.zig b/clap/comptime.zig
index f5c2762..f5c2762 100644
--- a/src/comptime.zig
+++ b/clap/comptime.zig
diff --git a/src/streaming.zig b/clap/streaming.zig
index b5c3498..fa7ce80 100644
--- a/src/streaming.zig
+++ b/clap/streaming.zig
@@ -321,7 +321,7 @@ test "clap.streaming.StreamingClap: all params" {
321 "-c", "0", "-c=0", "-ac", 321 "-c", "0", "-c=0", "-ac",
322 "0", "-ac=0", "--aa", "--bb", 322 "0", "-ac=0", "--aa", "--bb",
323 "--cc", "0", "--cc=0", "something", 323 "--cc", "0", "--cc=0", "something",
324 "--", "-", 324 "--", "-",
325 }, 325 },
326 [_]Arg(u8){ 326 [_]Arg(u8){
327 Arg(u8){ .param = aa }, 327 Arg(u8){ .param = aa },