mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 04:34:44 +00:00
Rename --dump flag to --html
--dump is still supported but deprecated
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user