Skip to content

Commit cab084e

Browse files
committed
Allow serving any renderer's output
1 parent 988ed9b commit cab084e

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/cmd/serve.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@ pub fn make_subcommand() -> Command {
4343
.value_parser(NonEmptyStringValueParser::new())
4444
.help("Port to use for HTTP connections"),
4545
)
46+
.arg(
47+
Arg::new("renderer")
48+
.short('r')
49+
.long("renderer")
50+
.num_args(1)
51+
.default_value("html")
52+
.value_parser(NonEmptyStringValueParser::new())
53+
.help("Renderer to serve the output of"),
54+
)
4655
.arg_open()
4756
.arg_watcher()
4857
}
@@ -54,6 +63,7 @@ pub fn execute(args: &ArgMatches) -> Result<()> {
5463

5564
let port = args.get_one::<String>("port").unwrap();
5665
let hostname = args.get_one::<String>("hostname").unwrap();
66+
let renderer = args.get_one::<String>("renderer").unwrap();
5767
let open_browser = args.get_flag("open");
5868

5969
let address = format!("{hostname}:{port}");
@@ -73,7 +83,7 @@ pub fn execute(args: &ArgMatches) -> Result<()> {
7383
.to_socket_addrs()?
7484
.next()
7585
.ok_or_else(|| anyhow::anyhow!("no address found for {}", address))?;
76-
let build_dir = book.build_dir_for("html");
86+
let build_dir = book.build_dir_for(renderer);
7787
let html_config = book.config.html_config();
7888
let input_404 = html_config.and_then(|c| c.input_404);
7989
let file_404 = get_404_output_file(&input_404);

0 commit comments

Comments
 (0)