From d3ba714aba9df652dd19358bcec0ed10539b6975 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Arrufat?= Date: Tue, 17 Feb 2026 00:35:15 +0900 Subject: [PATCH] Rename --dump flag to --html --dump is still supported but deprecated --- src/Config.zig | 20 +++++++++++++------- src/main.zig | 4 ++-- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/Config.zig b/src/Config.zig index e07f6b2f..071c74bb 100644 --- a/src/Config.zig +++ b/src/Config.zig @@ -165,7 +165,7 @@ pub const Serve = struct { pub const Fetch = struct { url: [:0]const u8, - dump: bool = false, + html: bool = false, markdown: bool = false, common: Common = .{}, withbase: bool = false, @@ -303,12 +303,14 @@ pub fn printUsageAndExit(self: *const Config, success: bool) void { \\ \\fetch command \\Fetches the specified URL - \\Example: {s} fetch --dump https://lightpanda.io/ + \\Example: {s} fetch --html https://lightpanda.io/ \\ \\Options: - \\--dump Dumps document to stdout. + \\--html Dumps document to stdout as HTML. \\ Defaults to false. \\ + \\--dump Alias for --html (deprecated). + \\ \\--markdown Dumps document to stdout as Markdown. \\ Defaults to false. \\ @@ -410,6 +412,10 @@ fn inferMode(opt: []const u8) ?RunMode { return .fetch; } + if (std.mem.eql(u8, opt, "--html")) { + return .fetch; + } + if (std.mem.eql(u8, opt, "--dump")) { return .fetch; } @@ -554,7 +560,7 @@ fn parseFetchArgs( allocator: Allocator, args: *std.process.ArgIterator, ) !Fetch { - var fetch_dump: bool = false; + var fetch_html: bool = false; var fetch_markdown: bool = false; var withbase: bool = false; var url: ?[:0]const u8 = null; @@ -562,8 +568,8 @@ fn parseFetchArgs( var strip: dump.Opts.Strip = .{}; while (args.next()) |opt| { - if (std.mem.eql(u8, "--dump", opt)) { - fetch_dump = true; + if (std.mem.eql(u8, "--html", opt) or std.mem.eql(u8, "--dump", opt)) { + fetch_html = true; continue; } @@ -635,7 +641,7 @@ fn parseFetchArgs( return .{ .url = url.?, - .dump = fetch_dump, + .html = fetch_html, .markdown = fetch_markdown, .strip = strip, .common = common, diff --git a/src/main.zig b/src/main.zig index 6a648ed1..25257533 100644 --- a/src/main.zig +++ b/src/main.zig @@ -107,7 +107,7 @@ fn run(allocator: Allocator, main_arena: Allocator) !void { }, .fetch => |opts| { const url = opts.url; - log.debug(.app, "startup", .{ .mode = "fetch", .dump = opts.dump, .url = url, .snapshot = app.snapshot.fromEmbedded() }); + log.debug(.app, "startup", .{ .mode = "fetch", .html = opts.html, .url = url, .snapshot = app.snapshot.fromEmbedded() }); var fetch_opts = lp.FetchOpts{ .wait_ms = 5000, @@ -120,7 +120,7 @@ fn run(allocator: Allocator, main_arena: Allocator) !void { var stdout = std.fs.File.stdout(); var writer = stdout.writer(&.{}); - if (opts.dump or opts.markdown) { + if (opts.html or opts.markdown) { fetch_opts.writer = &writer.interface; }