authorgravatar for 58830309+g-w1@users.noreply.github.comg-w1 <58830309+g-w1@users.noreply.github.com> 2020-11-11 08:54:08-05:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2020-11-11 15:54:08+02:00
log61c51f0ac96f91254c6acc6c23b8d09f38b49480
tree247635508b5e6374cc03b8837b5e6f401f823f7d
parent5872ae5111ae49f3e82e2d07f7c199d6550a1bd7
signature Signed by PGP key 4AEE18F83AFDEB23

Add error for missing positional arguments in zig build-*

Closes #6938

1 files changed, 10 insertions(+), 2 deletions(-)

src/main.zig+10-2
...@@ -1267,9 +1267,17 @@ fn buildOutputType(...@@ -1267,9 +1267,17 @@ fn buildOutputType(
1267 }1267 }
12681268
1269 if (link_objects.items.len == 0 and root_src_file == null and1269 if (link_objects.items.len == 0 and root_src_file == null and
1270 c_source_files.items.len == 0 and arg_mode == .run)1270 c_source_files.items.len == 0 and !show_builtin)
1271 {1271 {
1272 fatal("`zig run` expects at least one positional argument", .{});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 }
1273 }1281 }
12741282
1275 const root_name = if (provided_name) |n| n else blk: {1283 const root_name = if (provided_name) |n| n else blk: {