Skip to content

Lightpanda: the headless browser designed for AI and automation

fetch: namespace the dump options in Config too

Adrià Arrufat1fb7a1b983e9
diff --git a/src/Config.zig b/src/Config.zig
index 2a26867af..e0208dbe9 100644
--- a/src/Config.zig
+++ b/src/Config.zig
@@ -374,8 +374,8 @@ const Commands = cli.Builder(.{
.{ .name = "with_base", .type = bool },
.{ .name = "with_frames", .type = bool },
.{ .name = "strip_mode", .type = dump.Opts.Strip, .default = dump.Opts.Strip{} },
- .{ .name = "selector", .type = ?[:0]const u8 },
- .{ .name = "max_bytes", .type = ?u32 },
+ .{ .name = "dump_selector", .type = ?[:0]const u8 },
+ .{ .name = "dump_max_bytes", .type = ?u32 },
.{ .name = "wait_ms", .type = u32, .default = 5_000 },
.{ .name = "wait_until", .type = ?WaitUntil },
.{
diff --git a/src/help.zon b/src/help.zon
index eb1261899..60df687ad 100644
--- a/src/help.zon
+++ b/src/help.zon
@@ -72,6 +72,13 @@
\\ PNG image (base64 with --json).
\\ semantic_tree JSON-serialized semantic tree.
\\ semantic_tree_text Pruned plain-text semantic tree.
+ \\ --dump-max-bytes <INT>
+ \\ Soft cap on the dumped html or markdown, in bytes. Output is cut
+ \\ at a UTF-8 boundary and a '[truncated]' marker is appended.
+ \\ Defaults to no cap.
+ \\ --dump-selector <QUERY>
+ \\ Dump only the first element matching the CSS selector instead
+ \\ of the whole document. Fails if nothing matches.
\\ --inject-script <EXPR>
\\ JavaScript to execute as the document's <head> is parsed, before any
\\ other scripts in the page run. Can be passed multiple times; scripts
@@ -84,17 +91,10 @@
\\ prints one object; multiple URLs print {{"results": [ ... ]}} with
\\ one object per URL. When used with --dump <MODE> the dumped
\\ content is wrapped within each object.
- \\ --dump-max-bytes <INT>
- \\ Soft cap on the dumped html or markdown, in bytes. Output is cut
- \\ at a UTF-8 boundary and a '[truncated]' marker is appended.
- \\ Defaults to no cap.
\\ --metrics
\\ Write metrics (Prometheus text format) to stdout on exit, after
\\ any --dump output.
\\ Defaults to false.
- \\ --dump-duselector <QUERY>
- \\ Dump only the first element matching the CSS selector instead
- \\ of the whole document. Fails if nothing matches.
\\ --strip-mode <STRIP>
\\ Tag group to remove from dump. Can be passed multiple times.
\\ In markdown only 'ui' changes the output: scripts, styles and
diff --git a/src/main.zig b/src/main.zig
index ef0726458..01ccd4727 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -163,8 +163,8 @@ fn run(allocator: Allocator, main_arena: Allocator, proc_args: std.process.Args)
});
}
- if (opts.max_bytes != null and opts.dump != .html and opts.dump != .markdown) {
- log.fatal(.app, "--max-bytes needs a text dump", .{ .dump = opts.dump, .allowed = "html, markdown" });
+ if (opts.dump_max_bytes != null and opts.dump != .html and opts.dump != .markdown) {
+ log.fatal(.app, "--dump-max-bytes needs text", .{ .dump = opts.dump, .allowed = "html, markdown" });
return error.InvalidArgument;
}
@@ -175,8 +175,8 @@ fn run(allocator: Allocator, main_arena: Allocator, proc_args: std.process.Args)
.inject_script = opts.inject_script,
.wait_selector = opts.wait_selector,
.dump_mode = opts.dump,
- .selector = opts.selector,
- .max_bytes = opts.max_bytes,
+ .selector = opts.dump_selector,
+ .max_bytes = opts.dump_max_bytes,
.dump = .{
.strip = opts.strip_mode,
.with_base = opts.with_base,