Fix expected type error on 32 bit systems

fixes #23
This commit is contained in:
Jimmi Holst Christensen 2020-08-15 15:23:46 +02:00
parent 3187bd4841
commit ddca24a6fd
3 changed files with 11 additions and 8 deletions

View File

@ -46,9 +46,9 @@ pub fn main() !void {
if (args.flag("--help"))
debug.warn("--help\n", .{});
if (args.option("--number")) |n|
debug.warn("--number = {}\n", .{ n });
debug.warn("--number = {}\n", .{n});
for (args.positionals()) |pos|
debug.warn("{}\n", .{ pos });
debug.warn("{}\n", .{pos});
}
```
@ -125,9 +125,9 @@ pub fn main() !void {
if (args.flag("--help"))
debug.warn("--help\n", .{});
if (args.option("--number")) |n|
debug.warn("--number = {}\n", .{ n });
debug.warn("--number = {}\n", .{n});
for (args.positionals()) |pos|
debug.warn("{}\n", .{ pos });
debug.warn("{}\n", .{pos});
}
```
@ -179,12 +179,12 @@ pub fn main() !void {
// arg.param will point to the parameter which matched the argument.
switch (arg.param.id) {
'h' => debug.warn("Help!\n", .{}),
'n' => debug.warn("--number = {}\n", .{ arg.value.? }),
'n' => debug.warn("--number = {}\n", .{arg.value.?}),
// arg.value == null, if arg.param.takes_value == false.
// Otherwise, arg.value is the value passed with the argument, such as "-a=10"
// or "-a 10".
'f' => debug.warn("{}\n", .{ arg.value.? }),
'f' => debug.warn("{}\n", .{arg.value.?}),
else => unreachable,
}
}

View File

@ -6,6 +6,7 @@ const Builder = std.build.Builder;
pub fn build(b: *Builder) void {
const mode = b.standardReleaseOptions();
const target = b.standardTargetOptions(.{});
const fmt_step = b.addFmt(&[_][]const u8{
"build.zig",
@ -20,6 +21,7 @@ pub fn build(b: *Builder) void {
const tests = b.addTest("clap.zig");
tests.setBuildMode(test_mode);
tests.setTarget(target);
tests.setNamePrefix(mode_str ++ " ");
const test_step = b.step("test-" ++ mode_str, "Run all tests in " ++ mode_str ++ ".");
@ -39,6 +41,7 @@ pub fn build(b: *Builder) void {
const example = b.addExecutable(example_name, "example/" ++ example_name ++ ".zig");
example.addPackagePath("clap", "clap.zig");
example.setBuildMode(mode);
example.setTarget(target);
example.install();
example_step.dependOn(&example.step);
}

View File

@ -290,7 +290,7 @@ pub fn helpFull(
var counting_stream = io.countingOutStream(io.null_out_stream);
try printParam(counting_stream.outStream(), Id, param, Error, context, valueText);
if (res < counting_stream.bytes_written)
res = counting_stream.bytes_written;
res = @intCast(usize, counting_stream.bytes_written);
}
break :blk res;
@ -303,7 +303,7 @@ pub fn helpFull(
var counting_stream = io.countingOutStream(stream);
try stream.print("\t", .{});
try printParam(counting_stream.outStream(), Id, param, Error, context, valueText);
try stream.writeByteNTimes(' ', max_spacing - counting_stream.bytes_written);
try stream.writeByteNTimes(' ', max_spacing - @intCast(usize, counting_stream.bytes_written));
try stream.print("\t{}\n", .{try helpText(context, param)});
}
}