check for the index.html file first
This commit is contained in:
parent
1ca0d79f10
commit
d2d0aebecd
|
@ -2,6 +2,7 @@ use crate::{get_book_dir, open};
|
||||||
use clap::{arg, App, Arg, ArgMatches};
|
use clap::{arg, App, Arg, ArgMatches};
|
||||||
use mdbook::errors::Result;
|
use mdbook::errors::Result;
|
||||||
use mdbook::MDBook;
|
use mdbook::MDBook;
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
// Create clap subcommand arguments
|
// Create clap subcommand arguments
|
||||||
pub fn make_subcommand<'help>() -> App<'help> {
|
pub fn make_subcommand<'help>() -> App<'help> {
|
||||||
|
@ -39,11 +40,12 @@ pub fn execute(args: &ArgMatches) -> Result<()> {
|
||||||
if args.is_present("open") {
|
if args.is_present("open") {
|
||||||
// FIXME: What's the right behaviour if we don't use the HTML renderer?
|
// FIXME: What's the right behaviour if we don't use the HTML renderer?
|
||||||
let path = book.build_dir_for("html").join("index.html");
|
let path = book.build_dir_for("html").join("index.html");
|
||||||
if !path.exists() {
|
if !Path::new(&path).exists() {
|
||||||
error!("No chapter available to open");
|
error!("Need a more descriptive error here: {:?}", path);
|
||||||
std::process::exit(1)
|
std::process::exit(1);
|
||||||
}
|
}
|
||||||
open(path);
|
|
||||||
|
open(book.build_dir_for("html").join("index.html"));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Reference in New Issue