diff --git a/src/bin/build.rs b/src/bin/build.rs index 7ad127da..f3b595e1 100644 --- a/src/bin/build.rs +++ b/src/bin/build.rs @@ -1,4 +1,5 @@ -use clap::{App, ArgMatches, SubCommand}; +use std::path::PathBuf; +use clap::{ArgMatches, SubCommand, App}; use mdbook::MDBook; use mdbook::errors::Result; use {get_book_dir, open}; @@ -15,10 +16,6 @@ pub fn make_subcommand<'a, 'b>() -> App<'a, 'b> { .arg_from_usage( "--no-create 'Will not create non-existent files linked from SUMMARY.md'", ) - .arg_from_usage( - "--curly-quotes 'Convert straight quotes to curly quotes, except for those \ - that occur in code blocks and code spans'", - ) .arg_from_usage( "[dir] 'A directory for your book{n}(Defaults to Current Directory \ when omitted)'", @@ -28,21 +25,16 @@ pub fn make_subcommand<'a, 'b>() -> App<'a, 'b> { // Build command implementation pub fn execute(args: &ArgMatches) -> Result<()> { let book_dir = get_book_dir(args); - let book = MDBook::new(&book_dir).read_config()?; + let mut book = MDBook::new(&book_dir).read_config()?; - let mut book = match args.value_of("dest-dir") { - Some(dest_dir) => book.with_destination(dest_dir), - None => book, - }; + if let Some(dest_dir) = args.value_of("dest-dir") { + book.config.book.build_dir = PathBuf::from(dest_dir); + } if args.is_present("no-create") { book.create_missing = false; } - if args.is_present("curly-quotes") { - book = book.with_curly_quotes(true); - } - book.build()?; if args.is_present("open") { diff --git a/src/bin/init.rs b/src/bin/init.rs index 83431211..83ac54be 100644 --- a/src/bin/init.rs +++ b/src/bin/init.rs @@ -47,7 +47,7 @@ pub fn execute(args: &ArgMatches) -> Result<()> { } // Because of `src/book/mdbook.rs#L37-L39`, `dest` will always start with `root` - let is_dest_inside_root = book.get_destination().starts_with(book.get_root()); + let is_dest_inside_root = book.get_destination().starts_with(&book.root); if !args.is_present("force") && is_dest_inside_root { println!("\nDo you want a .gitignore to be created? (y/n)"); diff --git a/src/bin/serve.rs b/src/bin/serve.rs index c4f3a222..853fa237 100644 --- a/src/bin/serve.rs +++ b/src/bin/serve.rs @@ -3,7 +3,7 @@ extern crate staticfile; extern crate ws; use std; -use std::path::Path; +use std::path::{Path, PathBuf}; use self::iron::{status, AfterMiddleware, Chain, Iron, IronError, IronResult, Request, Response, Set}; use clap::{App, ArgMatches, SubCommand}; @@ -29,10 +29,6 @@ pub fn make_subcommand<'a, 'b>() -> App<'a, 'b> { "-d, --dest-dir=[dest-dir] 'The output directory for \ your book{n}(Defaults to ./book when omitted)'", ) - .arg_from_usage( - "--curly-quotes 'Convert straight quotes to curly quotes, except \ - for those that occur in code blocks and code spans'", - ) .arg_from_usage("-p, --port=[port] 'Use another port{n}(Defaults to 3000)'") .arg_from_usage( "-w, --websocket-port=[ws-port] 'Use another port for the \ @@ -53,15 +49,10 @@ pub fn execute(args: &ArgMatches) -> Result<()> { const RELOAD_COMMAND: &'static str = "reload"; let book_dir = get_book_dir(args); - let book = MDBook::new(&book_dir).read_config()?; + let mut book = MDBook::new(&book_dir).read_config()?; - let mut book = match args.value_of("dest-dir") { - Some(dest_dir) => book.with_destination(Path::new(dest_dir)), - None => book, - }; - - if args.is_present("curly-quotes") { - book = book.with_curly_quotes(true); + if let Some(dest_dir) = args.value_of("dest-dir") { + book.config.book.build_dir = PathBuf::from(dest_dir); } let port = args.value_of("port").unwrap_or("3000"); @@ -73,8 +64,7 @@ pub fn execute(args: &ArgMatches) -> Result<()> { let address = format!("{}:{}", interface, port); let ws_address = format!("{}:{}", interface, ws_port); - book.set_livereload(format!( - r#" + book.livereload = Some(format!(r#"