diff options
| -rw-r--r-- | build.zig | 2 | ||||
| -rw-r--r-- | clap.zig | 14 |
2 files changed, 9 insertions, 7 deletions
| @@ -59,7 +59,7 @@ fn readMeStep(b: *Builder) *std.build.Step { | |||
| 59 | fn make(step: *std.build.Step) anyerror!void { | 59 | fn make(step: *std.build.Step) anyerror!void { |
| 60 | @setEvalBranchQuota(10000); | 60 | @setEvalBranchQuota(10000); |
| 61 | const file = try std.fs.cwd().createFile("README.md", .{}); | 61 | const file = try std.fs.cwd().createFile("README.md", .{}); |
| 62 | const stream = &file.outStream().stream; | 62 | const stream = &file.outStream(); |
| 63 | try stream.print(@embedFile("example/README.md.template"), .{ | 63 | try stream.print(@embedFile("example/README.md.template"), .{ |
| 64 | @embedFile("example/simple.zig"), | 64 | @embedFile("example/simple.zig"), |
| 65 | @embedFile("example/simple-error.zig"), | 65 | @embedFile("example/simple-error.zig"), |
| @@ -282,8 +282,8 @@ pub fn helpFull( | |||
| 282 | const max_spacing = blk: { | 282 | const max_spacing = blk: { |
| 283 | var res: usize = 0; | 283 | var res: usize = 0; |
| 284 | for (params) |param| { | 284 | for (params) |param| { |
| 285 | var counting_stream = io.CountingOutStream(io.NullOutStream.Error).init(io.null_out_stream); | 285 | var counting_stream = io.countingOutStream(io.null_out_stream); |
| 286 | try printParam(&counting_stream.stream, Id, param, Error, context, value_text); | 286 | try printParam(&counting_stream.outStream(), Id, param, Error, context, value_text); |
| 287 | if (res < counting_stream.bytes_written) | 287 | if (res < counting_stream.bytes_written) |
| 288 | res = counting_stream.bytes_written; | 288 | res = counting_stream.bytes_written; |
| 289 | } | 289 | } |
| @@ -295,9 +295,9 @@ pub fn helpFull( | |||
| 295 | if (param.names.short == null and param.names.long == null) | 295 | if (param.names.short == null and param.names.long == null) |
| 296 | continue; | 296 | continue; |
| 297 | 297 | ||
| 298 | var counting_stream = io.CountingOutStream(@TypeOf(stream.*).Error).init(stream); | 298 | var counting_stream = io.countingOutStream(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.outStream(), 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 | } |
| @@ -385,9 +385,11 @@ fn getValueSimple(param: Param(Help)) []const u8 { | |||
| 385 | 385 | ||
| 386 | test "clap.help" { | 386 | test "clap.help" { |
| 387 | var buf: [1024]u8 = undefined; | 387 | var buf: [1024]u8 = undefined; |
| 388 | var slice_stream = io.SliceOutStream.init(buf[0..]); | 388 | var slice_stream = io.fixedBufferStream(&buf); |
| 389 | |||
| 390 | @setEvalBranchQuota(10000); | ||
| 389 | try help( | 391 | try help( |
| 390 | &slice_stream.stream, | 392 | slice_stream.outStream(), |
| 391 | comptime &[_]Param(Help){ | 393 | comptime &[_]Param(Help){ |
| 392 | parseParam("-a Short flag. ") catch unreachable, | 394 | parseParam("-a Short flag. ") catch unreachable, |
| 393 | parseParam("-b <V1> Short option.") catch unreachable, | 395 | parseParam("-b <V1> Short option.") catch unreachable, |