summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.zig2
-rw-r--r--clap.zig22
-rw-r--r--clap/args.zig4
-rw-r--r--clap/comptime.zig6
-rw-r--r--clap/streaming.zig2
5 files changed, 18 insertions, 18 deletions
diff --git a/build.zig b/build.zig
index 466f5d0..9baf1d4 100644
--- a/build.zig
+++ b/build.zig
@@ -62,7 +62,7 @@ pub fn build(b: *Builder) void {
62 62
63fn readMeStep(b: *Builder) *std.build.Step { 63fn readMeStep(b: *Builder) *std.build.Step {
64 const s = b.allocator.create(std.build.Step) catch unreachable; 64 const s = b.allocator.create(std.build.Step) catch unreachable;
65 s.* = std.build.Step.init("ReadMeStep", b.allocator, struct { 65 s.* = std.build.Step.init(.Custom, "ReadMeStep", b.allocator, struct {
66 fn make(step: *std.build.Step) anyerror!void { 66 fn make(step: *std.build.Step) anyerror!void {
67 @setEvalBranchQuota(10000); 67 @setEvalBranchQuota(10000);
68 const file = try std.fs.cwd().createFile("README.md", .{}); 68 const file = try std.fs.cwd().createFile("README.md", .{});
diff --git a/clap.zig b/clap.zig
index 8846d3b..8624c88 100644
--- a/clap.zig
+++ b/clap.zig
@@ -259,7 +259,7 @@ pub const Diagnostic = struct {
259 259
260 /// Default diagnostics reporter when all you want is English with no colors. 260 /// Default diagnostics reporter when all you want is English with no colors.
261 /// Use this as a reference for implementing your own if needed. 261 /// Use this as a reference for implementing your own if needed.
262 pub fn report(diag: Diagnostic, stream: var, err: anyerror) !void { 262 pub fn report(diag: Diagnostic, stream: anytype, err: anyerror) !void {
263 const Arg = struct { 263 const Arg = struct {
264 prefix: []const u8, 264 prefix: []const u8,
265 name: []const u8, 265 name: []const u8,
@@ -354,11 +354,11 @@ pub fn parse(
354/// --long helpText 354/// --long helpText
355/// --long <valueText> helpText 355/// --long <valueText> helpText
356pub fn helpFull( 356pub fn helpFull(
357 stream: var, 357 stream: anytype,
358 comptime Id: type, 358 comptime Id: type,
359 params: []const Param(Id), 359 params: []const Param(Id),
360 comptime Error: type, 360 comptime Error: type,
361 context: var, 361 context: anytype,
362 helpText: fn (@TypeOf(context), Param(Id)) Error![]const u8, 362 helpText: fn (@TypeOf(context), Param(Id)) Error![]const u8,
363 valueText: fn (@TypeOf(context), Param(Id)) Error![]const u8, 363 valueText: fn (@TypeOf(context), Param(Id)) Error![]const u8,
364) !void { 364) !void {
@@ -387,11 +387,11 @@ pub fn helpFull(
387} 387}
388 388
389fn printParam( 389fn printParam(
390 stream: var, 390 stream: anytype,
391 comptime Id: type, 391 comptime Id: type,
392 param: Param(Id), 392 param: Param(Id),
393 comptime Error: type, 393 comptime Error: type,
394 context: var, 394 context: anytype,
395 valueText: fn (@TypeOf(context), Param(Id)) Error![]const u8, 395 valueText: fn (@TypeOf(context), Param(Id)) Error![]const u8,
396) !void { 396) !void {
397 if (param.names.short) |s| { 397 if (param.names.short) |s| {
@@ -419,7 +419,7 @@ fn printParam(
419/// A wrapper around helpFull for simple helpText and valueText functions that 419/// A wrapper around helpFull for simple helpText and valueText functions that
420/// cant return an error or take a context. 420/// cant return an error or take a context.
421pub fn helpEx( 421pub fn helpEx(
422 stream: var, 422 stream: anytype,
423 comptime Id: type, 423 comptime Id: type,
424 params: []const Param(Id), 424 params: []const Param(Id),
425 helpText: fn (Param(Id)) []const u8, 425 helpText: fn (Param(Id)) []const u8,
@@ -458,7 +458,7 @@ pub const Help = struct {
458}; 458};
459 459
460/// A wrapper around helpEx that takes a Param(Help). 460/// A wrapper around helpEx that takes a Param(Help).
461pub fn help(stream: var, params: []const Param(Help)) !void { 461pub fn help(stream: anytype, params: []const Param(Help)) !void {
462 try helpEx(stream, Help, params, getHelpSimple, getValueSimple); 462 try helpEx(stream, Help, params, getHelpSimple, getValueSimple);
463} 463}
464 464
@@ -512,11 +512,11 @@ test "clap.help" {
512/// First all none value taking parameters, which have a short name are 512/// First all none value taking parameters, which have a short name are
513/// printed, then non positional parameters and finally the positinal. 513/// printed, then non positional parameters and finally the positinal.
514pub fn usageFull( 514pub fn usageFull(
515 stream: var, 515 stream: anytype,
516 comptime Id: type, 516 comptime Id: type,
517 params: []const Param(Id), 517 params: []const Param(Id),
518 comptime Error: type, 518 comptime Error: type,
519 context: var, 519 context: anytype,
520 valueText: fn (@TypeOf(context), Param(Id)) Error![]const u8, 520 valueText: fn (@TypeOf(context), Param(Id)) Error![]const u8,
521) !void { 521) !void {
522 var cos = io.countingOutStream(stream); 522 var cos = io.countingOutStream(stream);
@@ -569,7 +569,7 @@ pub fn usageFull(
569/// A wrapper around usageFull for a simple valueText functions that 569/// A wrapper around usageFull for a simple valueText functions that
570/// cant return an error or take a context. 570/// cant return an error or take a context.
571pub fn usageEx( 571pub fn usageEx(
572 stream: var, 572 stream: anytype,
573 comptime Id: type, 573 comptime Id: type,
574 params: []const Param(Id), 574 params: []const Param(Id),
575 valueText: fn (Param(Id)) []const u8, 575 valueText: fn (Param(Id)) []const u8,
@@ -593,7 +593,7 @@ pub fn usageEx(
593} 593}
594 594
595/// A wrapper around usageEx that takes a Param(Help). 595/// A wrapper around usageEx that takes a Param(Help).
596pub fn usage(stream: var, params: []const Param(Help)) !void { 596pub fn usage(stream: anytype, params: []const Param(Help)) !void {
597 try usageEx(stream, Help, params, getValueSimple); 597 try usageEx(stream, Help, params, getValueSimple);
598} 598}
599 599
diff --git a/clap/args.zig b/clap/args.zig
index 0105769..52626fc 100644
--- a/clap/args.zig
+++ b/clap/args.zig
@@ -53,7 +53,7 @@ pub const OsIterator = struct {
53 /// The executable path (this is the first argument passed to the program) 53 /// The executable path (this is the first argument passed to the program)
54 /// TODO: Is it the right choice for this to be null? Maybe `init` should 54 /// TODO: Is it the right choice for this to be null? Maybe `init` should
55 /// return an error when we have no exe. 55 /// return an error when we have no exe.
56 exe_arg: ?[]const u8, 56 exe_arg: ?[:0]const u8,
57 57
58 pub fn init(allocator: *mem.Allocator) Error!OsIterator { 58 pub fn init(allocator: *mem.Allocator) Error!OsIterator {
59 var res = OsIterator{ 59 var res = OsIterator{
@@ -69,7 +69,7 @@ pub const OsIterator = struct {
69 iter.arena.deinit(); 69 iter.arena.deinit();
70 } 70 }
71 71
72 pub fn next(iter: *OsIterator) Error!?[]const u8 { 72 pub fn next(iter: *OsIterator) Error!?[:0]const u8 {
73 if (builtin.os.tag == .windows) { 73 if (builtin.os.tag == .windows) {
74 return try iter.args.next(&iter.arena.allocator) orelse return null; 74 return try iter.args.next(&iter.arena.allocator) orelse return null;
75 } else { 75 } else {
diff --git a/clap/comptime.zig b/clap/comptime.zig
index 9ead41a..80eb428 100644
--- a/clap/comptime.zig
+++ b/clap/comptime.zig
@@ -169,10 +169,10 @@ test "" {
169 testing.expect(args.flag("--aa")); 169 testing.expect(args.flag("--aa"));
170 testing.expect(!args.flag("-b")); 170 testing.expect(!args.flag("-b"));
171 testing.expect(!args.flag("--bb")); 171 testing.expect(!args.flag("--bb"));
172 testing.expectEqualSlices(u8, "0", args.option("-c").?); 172 testing.expectEqualStrings("0", args.option("-c").?);
173 testing.expectEqualSlices(u8, "0", args.option("--cc").?); 173 testing.expectEqualStrings("0", args.option("--cc").?);
174 testing.expectEqual(@as(usize, 1), args.positionals().len); 174 testing.expectEqual(@as(usize, 1), args.positionals().len);
175 testing.expectEqualSlices(u8, "something", args.positionals()[0]); 175 testing.expectEqualStrings("something", args.positionals()[0]);
176 testing.expectEqualSlices([]const u8, &[_][]const u8{ "a", "b" }, args.options("-d")); 176 testing.expectEqualSlices([]const u8, &[_][]const u8{ "a", "b" }, args.options("-d"));
177 testing.expectEqualSlices([]const u8, &[_][]const u8{ "a", "b" }, args.options("--dd")); 177 testing.expectEqualSlices([]const u8, &[_][]const u8{ "a", "b" }, args.options("--dd"));
178} 178}
diff --git a/clap/streaming.zig b/clap/streaming.zig
index e0b808e..844cbf7 100644
--- a/clap/streaming.zig
+++ b/clap/streaming.zig
@@ -167,7 +167,7 @@ pub fn StreamingClap(comptime Id: type, comptime ArgIterator: type) type {
167 return err(diag, arg, .{ .short = arg[index] }, error.InvalidArgument); 167 return err(diag, arg, .{ .short = arg[index] }, error.InvalidArgument);
168 } 168 }
169 169
170 fn err(diag: ?*clap.Diagnostic, arg: []const u8, names: clap.Names, _err: var) @TypeOf(_err) { 170 fn err(diag: ?*clap.Diagnostic, arg: []const u8, names: clap.Names, _err: anytype) @TypeOf(_err) {
171 if (diag) |d| 171 if (diag) |d|
172 d.* = .{ .arg = arg, .name = names }; 172 d.* = .{ .arg = arg, .name = names };
173 return _err; 173 return _err;