authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-11-11 19:35:07-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-11-11 19:35:07-07:00
log2d42532fec06d25a1d56b2696e59f52922d6168a
tree5736980cf75c3a51f539edd64ca813db6088b780
parentbf73db71f531c37b73616fb9bf5145c014521f6a

main: clean up the error message for missing positional args


1 files changed, 5 insertions(+), 16 deletions(-)

src/main.zig+5-16
......@@ -1266,20 +1266,6 @@ fn buildOutputType(
12661266 fatal("`zig test` expects a zig source file argument", .{});
12671267 }
12681268
1269 if (link_objects.items.len == 0 and root_src_file == null and
1270 c_source_files.items.len == 0 and !show_builtin)
1271 {
1272 switch (arg_mode) {
1273 .run => fatal("`zig run` expects at least one positional argument", .{}),
1274 .build => |build_type| switch (build_type) {
1275 .Exe => fatal("`zig build-exe` expects at least one positional argument", .{}),
1276 .Lib => fatal("`zig build-lib` expects at least one positional argument", .{}),
1277 .Obj => fatal("`zig build-obj` expects at least one positional argument", .{}),
1278 },
1279 else => {},
1280 }
1281 }
1282
12831269 const root_name = if (provided_name) |n| n else blk: {
12841270 if (arg_mode == .zig_test) {
12851271 break :blk "test";
......@@ -1298,9 +1284,12 @@ fn buildOutputType(
12981284 } else if (show_builtin) {
12991285 break :blk "builtin";
13001286 } else if (arg_mode == .run) {
1301 break :blk "run";
1287 fatal("`zig run` expects at least one positional argument", .{});
1288 // TODO once the attempt to unwrap error: LinkingWithoutZigSourceUnimplemented
1289 // is solved, remove the above fatal() and uncomment the `break` below.
1290 //break :blk "run";
13021291 } else {
1303 fatal("--name [name] not provided and unable to infer", .{});
1292 fatal("expected a positional argument, -femit-bin=[path], --show-builtin, or --name [name]", .{});
13041293 }
13051294 };
13061295