2017-06-26 07:24:33 +08:00
|
|
|
use clap::{ArgMatches, SubCommand, App};
|
|
|
|
use mdbook::MDBook;
|
2017-06-27 05:17:46 +08:00
|
|
|
use mdbook::errors::Result;
|
2017-06-26 07:24:33 +08:00
|
|
|
use get_book_dir;
|
|
|
|
|
2017-06-27 13:59:50 +08:00
|
|
|
// Create clap subcommand arguments
|
|
|
|
pub fn make_subcommand<'a, 'b>() -> App<'a, 'b> {
|
|
|
|
SubCommand::with_name("test").about("Test that code samples compile")
|
|
|
|
}
|
|
|
|
|
2017-06-26 07:24:33 +08:00
|
|
|
// test command implementation
|
2017-06-27 13:59:50 +08:00
|
|
|
pub fn execute(args: &ArgMatches) -> Result<()> {
|
2017-06-26 07:24:33 +08:00
|
|
|
let book_dir = get_book_dir(args);
|
|
|
|
let mut book = MDBook::new(&book_dir).read_config()?;
|
|
|
|
|
|
|
|
book.test()?;
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|