@@ -134,7 +134,10 @@ fn run(alloc: Allocator) !void {
134134
135135 // dump
136136 if (opts .dump ) {
137- try page .dump (.{ .exclude_scripts = opts .noscript }, std .io .getStdOut ());
137+ try page .dump (.{
138+ .exclude_scripts = opts .noscript ,
139+ .include_base = if (opts .withbase ) page .url .raw else null ,
140+ }, std .io .getStdOut ());
138141 }
139142 },
140143 else = > unreachable ,
@@ -213,6 +216,7 @@ const Command = struct {
213216 dump : bool = false ,
214217 common : Common ,
215218 noscript : bool = false ,
219+ withbase : bool = false ,
216220 };
217221
218222 const Common = struct {
@@ -277,6 +281,7 @@ const Command = struct {
277281 \\--dump Dumps document to stdout.
278282 \\ Defaults to false.
279283 \\--noscript Exclude <script> tags in dump. Defaults to false.
284+ \\--with_base Add a <base> tag in dump. Defaults to false.
280285 \\
281286 ++ common_options ++
282287 \\
@@ -351,13 +356,19 @@ fn inferMode(opt: []const u8) ?App.RunMode {
351356 return .serve ;
352357 }
353358
359+ if (std .mem .startsWith (u8 , opt , "--" ) == false ) {
360+ return .fetch ;
361+ }
362+
354363 if (std .mem .eql (u8 , opt , "--dump" )) {
355364 return .fetch ;
356365 }
366+
357367 if (std .mem .eql (u8 , opt , "--noscript" )) {
358368 return .fetch ;
359369 }
360- if (std .mem .startsWith (u8 , opt , "--" ) == false ) {
370+
371+ if (std .mem .eql (u8 , opt , "--with_base" )) {
361372 return .fetch ;
362373 }
363374
@@ -443,6 +454,7 @@ fn parseFetchArgs(
443454) ! Command.Fetch {
444455 var dump : bool = false ;
445456 var noscript : bool = false ;
457+ var withbase : bool = false ;
446458 var url : ? []const u8 = null ;
447459 var common : Command.Common = .{};
448460
@@ -457,6 +469,11 @@ fn parseFetchArgs(
457469 continue ;
458470 }
459471
472+ if (std .mem .eql (u8 , "--with_base" , opt )) {
473+ withbase = true ;
474+ continue ;
475+ }
476+
460477 if (try parseCommonArg (allocator , opt , args , & common )) {
461478 continue ;
462479 }
@@ -483,6 +500,7 @@ fn parseFetchArgs(
483500 .dump = dump ,
484501 .common = common ,
485502 .noscript = noscript ,
503+ .withbase = withbase ,
486504 };
487505}
488506
0 commit comments