call first_chapter

This commit is contained in:
josh rotenberg 2022-05-10 11:19:23 -07:00
parent 29c729fd23
commit 8b49600673
1 changed files with 7 additions and 1 deletions

View File

@ -1,3 +1,4 @@
use crate::first_chapter;
use crate::{get_book_dir, open};
use clap::{arg, App, Arg, ArgMatches};
use mdbook::errors::Result;
@ -45,7 +46,12 @@ pub fn execute(args: &ArgMatches) -> Result<()> {
if args.is_present("open") {
book.build()?;
open(book.build_dir_for("html").join("index.html"));
match first_chapter(&book)
.map(|path| book.build_dir_for("html").join(path).with_extension("html"))
{
Some(path) if Path::new(&path).exists() => open(path),
_ => warn!("No chapter available to open"),
}
}
trigger_on_change(&book, |paths, book_dir| {