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 {
|
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,
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user