Rename --dump flag to --html

--dump is still supported but deprecated
This commit is contained in:
Adrià Arrufat
2026-02-17 00:35:15 +09:00
parent 748b37f1d6
commit d3ba714aba
2 changed files with 15 additions and 9 deletions

View File

@@ -165,7 +165,7 @@ pub const Serve = struct {
pub const Fetch = struct { pub const Fetch = struct {
url: [:0]const u8, url: [:0]const u8,
dump: bool = false, html: bool = false,
markdown: bool = false, markdown: bool = false,
common: Common = .{}, common: Common = .{},
withbase: bool = false, withbase: bool = false,
@@ -303,12 +303,14 @@ pub fn printUsageAndExit(self: *const Config, success: bool) void {
\\ \\
\\fetch command \\fetch command
\\Fetches the specified URL \\Fetches the specified URL
\\Example: {s} fetch --dump https://lightpanda.io/ \\Example: {s} fetch --html https://lightpanda.io/
\\ \\
\\Options: \\Options:
\\--dump Dumps document to stdout. \\--html Dumps document to stdout as HTML.
\\ Defaults to false. \\ Defaults to false.
\\ \\
\\--dump Alias for --html (deprecated).
\\
\\--markdown Dumps document to stdout as Markdown. \\--markdown Dumps document to stdout as Markdown.
\\ Defaults to false. \\ Defaults to false.
\\ \\
@@ -410,6 +412,10 @@ fn inferMode(opt: []const u8) ?RunMode {
return .fetch; return .fetch;
} }
if (std.mem.eql(u8, opt, "--html")) {
return .fetch;
}
if (std.mem.eql(u8, opt, "--dump")) { if (std.mem.eql(u8, opt, "--dump")) {
return .fetch; return .fetch;
} }
@@ -554,7 +560,7 @@ fn parseFetchArgs(
allocator: Allocator, allocator: Allocator,
args: *std.process.ArgIterator, args: *std.process.ArgIterator,
) !Fetch { ) !Fetch {
var fetch_dump: bool = false; var fetch_html: bool = false;
var fetch_markdown: bool = false; var fetch_markdown: bool = false;
var withbase: bool = false; var withbase: bool = false;
var url: ?[:0]const u8 = null; var url: ?[:0]const u8 = null;
@@ -562,8 +568,8 @@ fn parseFetchArgs(
var strip: dump.Opts.Strip = .{}; var strip: dump.Opts.Strip = .{};
while (args.next()) |opt| { while (args.next()) |opt| {
if (std.mem.eql(u8, "--dump", opt)) { if (std.mem.eql(u8, "--html", opt) or std.mem.eql(u8, "--dump", opt)) {
fetch_dump = true; fetch_html = true;
continue; continue;
} }
@@ -635,7 +641,7 @@ fn parseFetchArgs(
return .{ return .{
.url = url.?, .url = url.?,
.dump = fetch_dump, .html = fetch_html,
.markdown = fetch_markdown, .markdown = fetch_markdown,
.strip = strip, .strip = strip,
.common = common, .common = common,

View File

@@ -107,7 +107,7 @@ fn run(allocator: Allocator, main_arena: Allocator) !void {
}, },
.fetch => |opts| { .fetch => |opts| {
const url = opts.url; 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{ var fetch_opts = lp.FetchOpts{
.wait_ms = 5000, .wait_ms = 5000,
@@ -120,7 +120,7 @@ fn run(allocator: Allocator, main_arena: Allocator) !void {
var stdout = std.fs.File.stdout(); var stdout = std.fs.File.stdout();
var writer = stdout.writer(&.{}); var writer = stdout.writer(&.{});
if (opts.dump or opts.markdown) { if (opts.html or opts.markdown) {
fetch_opts.writer = &writer.interface; fetch_opts.writer = &writer.interface;
} }