From dfce396cf865e5cc05f46f3079e25c5acb98a4c3 Mon Sep 17 00:00:00 2001 From: g-w1 Date: Fri, 9 Oct 2020 16:34:39 -0400 Subject: [PATCH 1/2] friendly error message for zig run with no args --- src/main.zig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main.zig b/src/main.zig index b43086ccc..a4c2f4f47 100644 --- a/src/main.zig +++ b/src/main.zig @@ -1269,6 +1269,10 @@ fn buildOutputType( fatal("one zig source file is required to run `zig test`", .{}); } + if (link_objects.items.len == 0 and root_src_file == null and c_source_files.items.len == 0 and arg_mode == .run) { + fatal("one source file is required to run `zig run`", .{}); + } + const root_name = if (provided_name) |n| n else blk: { if (arg_mode == .zig_test) { break :blk "test"; From 09a250c531afb95f475d6834a50f1aecc4761b39 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 15 Oct 2020 17:42:19 -0700 Subject: [PATCH 2/2] adjust error message of zig run with no args previously it said "one source file" which was not correct --- src/main.zig | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main.zig b/src/main.zig index a4c2f4f47..433d64925 100644 --- a/src/main.zig +++ b/src/main.zig @@ -1266,11 +1266,13 @@ fn buildOutputType( } if (root_src_file == null and arg_mode == .zig_test) { - fatal("one zig source file is required to run `zig test`", .{}); + fatal("`zig test` expects a zig source file argument", .{}); } - if (link_objects.items.len == 0 and root_src_file == null and c_source_files.items.len == 0 and arg_mode == .run) { - fatal("one source file is required to run `zig run`", .{}); + if (link_objects.items.len == 0 and root_src_file == null and + c_source_files.items.len == 0 and arg_mode == .run) + { + fatal("`zig run` expects at least one positional argument", .{}); } const root_name = if (provided_name) |n| n else blk: {