summaryrefslogtreecommitdiff
path: root/clap.zig
diff options
context:
space:
mode:
authorGravatar dbandstra2019-12-09 20:03:39 -0800
committerGravatar dbandstra2019-12-09 20:09:16 -0800
commitc5f6c0861d5a9d69783ec8838b97eedc38932b34 (patch)
tree312476823228ea69da8773817185cccec78acfaa /clap.zig
parentMerge pull request #12 from dbandstra/update-for-latest-zig (diff)
downloadzig-clap-c5f6c0861d5a9d69783ec8838b97eedc38932b34.tar.gz
zig-clap-c5f6c0861d5a9d69783ec8838b97eedc38932b34.tar.xz
zig-clap-c5f6c0861d5a9d69783ec8838b97eedc38932b34.zip
update for latest zig (varargs is no more)
Diffstat (limited to 'clap.zig')
-rw-r--r--clap.zig32
1 files changed, 16 insertions, 16 deletions
diff --git a/clap.zig b/clap.zig
index 2026d95..a300266 100644
--- a/clap.zig
+++ b/clap.zig
@@ -296,10 +296,10 @@ pub fn helpFull(
296 continue; 296 continue;
297 297
298 var counting_stream = io.CountingOutStream(@typeOf(stream.*).Error).init(stream); 298 var counting_stream = io.CountingOutStream(@typeOf(stream.*).Error).init(stream);
299 try stream.print("\t"); 299 try stream.print("\t", .{});
300 try printParam(&counting_stream.stream, Id, param, Error, context, value_text); 300 try printParam(&counting_stream.stream, Id, param, Error, context, value_text);
301 try stream.writeByteNTimes(' ', max_spacing - counting_stream.bytes_written); 301 try stream.writeByteNTimes(' ', max_spacing - counting_stream.bytes_written);
302 try stream.print("\t{}\n", try help_text(context, param)); 302 try stream.print("\t{}\n", .{ try help_text(context, param) });
303 } 303 }
304} 304}
305 305
@@ -312,21 +312,21 @@ fn printParam(
312 value_text: fn (@typeOf(context), Param(Id)) Error![]const u8, 312 value_text: fn (@typeOf(context), Param(Id)) Error![]const u8,
313) @typeOf(stream.*).Error!void { 313) @typeOf(stream.*).Error!void {
314 if (param.names.short) |s| { 314 if (param.names.short) |s| {
315 try stream.print("-{c}", s); 315 try stream.print("-{c}", .{ s });
316 } else { 316 } else {
317 try stream.print(" "); 317 try stream.print(" ", .{});
318 } 318 }
319 if (param.names.long) |l| { 319 if (param.names.long) |l| {
320 if (param.names.short) |_| { 320 if (param.names.short) |_| {
321 try stream.print(", "); 321 try stream.print(", ", .{});
322 } else { 322 } else {
323 try stream.print(" "); 323 try stream.print(" ", .{});
324 } 324 }
325 325
326 try stream.print("--{}", l); 326 try stream.print("--{}", .{ l });
327 } 327 }
328 if (param.takes_value) 328 if (param.takes_value)
329 try stream.print(" <{}>", value_text(context, param)); 329 try stream.print(" <{}>", .{ value_text(context, param) });
330} 330}
331 331
332/// A wrapper around helpFull for simple help_text and value_text functions that 332/// A wrapper around helpFull for simple help_text and value_text functions that
@@ -414,18 +414,18 @@ test "clap.help" {
414 414
415 const actual = slice_stream.getWritten(); 415 const actual = slice_stream.getWritten();
416 if (!mem.eql(u8, actual, expected)) { 416 if (!mem.eql(u8, actual, expected)) {
417 debug.warn("\n============ Expected ============\n"); 417 debug.warn("\n============ Expected ============\n", .{});
418 debug.warn("{}", expected); 418 debug.warn("{}", .{ expected });
419 debug.warn("============= Actual =============\n"); 419 debug.warn("============= Actual =============\n", .{});
420 debug.warn("{}", actual); 420 debug.warn("{}", .{ actual });
421 421
422 var buffer: [1024 * 2]u8 = undefined; 422 var buffer: [1024 * 2]u8 = undefined;
423 var fba = std.heap.FixedBufferAllocator.init(&buffer); 423 var fba = std.heap.FixedBufferAllocator.init(&buffer);
424 424
425 debug.warn("============ Expected (escaped) ============\n"); 425 debug.warn("============ Expected (escaped) ============\n", .{});
426 debug.warn("{x}\n", expected); 426 debug.warn("{x}\n", .{ expected });
427 debug.warn("============ Actual (escaped) ============\n"); 427 debug.warn("============ Actual (escaped) ============\n", .{});
428 debug.warn("{x}\n", actual); 428 debug.warn("{x}\n", .{ actual });
429 testing.expect(false); 429 testing.expect(false);
430 } 430 }
431} 431}