Skip to content

Lightpanda: the headless browser designed for AI and automation

add `update` command and make it runnable in main

Halil Durak6919400c4272
diff --git a/src/lightpanda.zig b/src/lightpanda.zig
index 4dfdbc437..21840e2f4 100644
--- a/src/lightpanda.zig
+++ b/src/lightpanda.zig
@@ -56,6 +56,8 @@ pub const build_config = @import("build_config");
pub const crash_handler = @import("crash_handler.zig");
pub const core_dump = @import("core_dump.zig");
+pub const Updater = @import("Updater.zig");
+
pub const FetchOpts = struct {
wait_ms: u32 = 5000,
wait_until: ?Config.WaitUntil = null,
@@ -223,6 +225,16 @@ fn dumpContent(app: *App, mode: Config.DumpFormat, dump_opts: dump.Opts, frame:
}
}
+/// Check `Config.zig` for `options`.
+pub fn update(allocator: std.mem.Allocator, config: *const Config, options: anytype) !void {
+ if (options.channel == .nightly) @panic("TODO");
+
+ var client = try Updater.init(allocator, config);
+ defer client.deinit();
+
+ try client.getVersions();
+}
+
// Writes a single page's result object. Framing (the enclosing array and any
// separators / trailing newline) is the caller's responsibility.
fn writeJsonEnvelope(writer: *std.Io.Writer, frame: ?*Frame, dump_mode: ?Config.DumpFormat, content: []const u8) !void {
diff --git a/src/main.zig b/src/main.zig
index ca0b75325..a733b0ba6 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -80,6 +80,10 @@ fn run(allocator: Allocator, main_arena: Allocator) !void {
try lp.Agent.listModels(allocator, opts);
return std.process.cleanExit();
},
+ .update => |options| {
+ try lp.update(allocator, &args, options);
+ return std.process.cleanExit();
+ },
else => {},
}