From 23054dc393feac813c4cddecf59b164cd3e77e63 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 15 Sep 2023 17:14:12 -0700 Subject: [PATCH] main: only check for CLI actions on non-lib builds --- src/main.zig | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main.zig b/src/main.zig index 936c167d7..10a9d62ae 100644 --- a/src/main.zig +++ b/src/main.zig @@ -201,12 +201,15 @@ pub const GlobalState = struct { }; // We first try to parse any action that we may be executing. - self.action = try cli_action.Action.detectCLI(self.alloc); + // We do not execute this in the lib because os.argv is not set. + if (comptime build_config.artifact != .lib) { + self.action = try cli_action.Action.detectCLI(self.alloc); - // If we have an action executing, we disable logging by default - // since we write to stderr we don't want logs messing up our - // output. - if (self.action != null) self.logging = .{ .disabled = {} }; + // If we have an action executing, we disable logging by default + // since we write to stderr we don't want logs messing up our + // output. + if (self.action != null) self.logging = .{ .disabled = {} }; + } // I don't love the env var name but I don't have it in my heart // to parse CLI args 3 times (once for actions, once for config,