Skip to content

Lightpanda: the headless browser designed for AI and automation

move `update` command to `version --check`

Halil Durakd8184dc462f0
diff --git a/src/Config.zig b/src/Config.zig
index 2ffa5fec3..cc2a0e5ad 100644
--- a/src/Config.zig
+++ b/src/Config.zig
@@ -262,8 +262,9 @@ const Commands = cli.Builder(.{
},
.shared_options = CommonOptions,
},
- .{ .name = "update", .options = .{}, .shared_options = CommonOptions },
- .{ .name = "version", .options = .{} },
+ .{ .name = "version", .options = .{
+ .{ .name = "check", .type = bool },
+ } },
});
pub const RunMode = Commands.Enum;
@@ -275,7 +276,11 @@ exec_name: []const u8,
http_headers: HttpHeaders,
fn modeNeedsHttp(mode: Mode) bool {
- return mode != .help and mode != .version;
+ return switch (mode) {
+ .help => false,
+ .version => |opts| opts.check,
+ else => true,
+ };
}
pub fn init(allocator: Allocator, exec_name: []const u8, mode: Mode) !Config {
@@ -308,6 +313,8 @@ pub fn interactive(self: *const Config) bool {
pub fn tlsVerifyHost(self: *const Config) bool {
return switch (self.mode) {
inline .serve, .fetch, .mcp, .agent => |opts| !opts.insecure_disable_tls_host_verification,
+ // `version --check` talks to the release endpoint; always verify.
+ .version => true,
else => unreachable,
};
}
@@ -356,7 +363,8 @@ pub fn v8MaxHeapMb(self: *const Config) ?u32 {
pub fn httpProxy(self: *const Config) ?[:0]const u8 {
return switch (self.mode) {
- inline .serve, .fetch, .mcp, .agent, .update => |opts| opts.http_proxy,
+ inline .serve, .fetch, .mcp, .agent => |opts| opts.http_proxy,
+ .version => null,
else => unreachable,
};
}
@@ -384,14 +392,16 @@ pub fn httpMaxHostOpen(self: *const Config) u8 {
pub fn httpConnectTimeout(self: *const Config) u31 {
return switch (self.mode) {
- inline .serve, .fetch, .mcp, .agent, .update => |opts| opts.http_connect_timeout orelse 0,
+ inline .serve, .fetch, .mcp, .agent => |opts| opts.http_connect_timeout orelse 0,
+ .version => 0,
else => unreachable,
};
}
pub fn httpTimeout(self: *const Config) u31 {
return switch (self.mode) {
- inline .serve, .fetch, .mcp, .agent, .update => |opts| opts.http_timeout orelse 5000,
+ inline .serve, .fetch, .mcp, .agent => |opts| opts.http_timeout orelse 5000,
+ .version => 5000,
else => unreachable,
};
}
@@ -402,7 +412,7 @@ pub fn httpMaxRedirects(_: *const Config) u8 {
pub fn httpMaxResponseSize(self: *const Config) ?usize {
return switch (self.mode) {
- inline .serve, .fetch, .mcp, .agent, .update => |opts| opts.http_max_response_size,
+ inline .serve, .fetch, .mcp, .agent => |opts| opts.http_max_response_size,
else => unreachable,
};
}
@@ -692,7 +702,7 @@ pub fn printUsageAndExit(self: *const Config, help_for: RunMode, success: bool)
, .{Help.general});
std.debug.print(template, .{exec_name});
},
- inline .fetch, .serve, .mcp, .agent, .update => |tag| {
+ inline .fetch, .serve, .mcp, .agent => |tag| {
const template = comptimePrint(
\\{s}
\\
diff --git a/src/help.zon b/src/help.zon
index 2622c655e..08eb8c7fc 100644
--- a/src/help.zon
+++ b/src/help.zon
@@ -237,16 +237,16 @@
\\MISTRAL_API_KEY. The local servers (Ollama, llama.cpp) do not require an
\\API key.
,
- .update =
- \\usage: {0s} update [COMMON_OPTIONS]
- \\
- \\Checks whether a newer release of {0s} is available. When one is found,
- \\prints the running version, the latest release, and how to update.
- ,
.version =
- \\usage: {0s} version
+ \\usage: {0s} version [OPTIONS]
\\
\\Displays the version of {0s}.
+ \\
+ \\options:
+ \\ --check
+ \\ Checks whether a newer release of {0s} is available. When one is
+ \\ found, prints the running version, the latest release, and how to
+ \\ update.
,
.help =
\\usage: {0s} help
diff --git a/src/main.zig b/src/main.zig
index 8d8442f0b..ca0b75325 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -80,10 +80,6 @@ fn run(allocator: Allocator, main_arena: Allocator) !void {
try lp.Agent.listModels(allocator, opts);
return std.process.cleanExit();
},
- .update => {
- try lp.update(allocator, &args);
- return std.process.cleanExit();
- },
else => {},
}