diff --git a/src/cmd/shelf.rs b/src/cmd/shelf.rs index b3ee745ba3..c0c10b3cf8 100644 --- a/src/cmd/shelf.rs +++ b/src/cmd/shelf.rs @@ -59,17 +59,20 @@ pub fn execute(_args: &ArgMatches) -> Result<()> { let _ = std::fs::remove_dir_all("shelf"); let _ = std::fs::remove_dir_all("repositories"); - let _ = MDBook::init("shelf").create_gitignore(false).build(); + let shelf_book = MDBook::init("shelf").create_gitignore(false).build()?; - let index_file_name = "shelf/src/index.md"; + let mut index_file_name = shelf_book.source_dir(); + index_file_name.push("index.md"); let mut index_file = File::create(index_file_name).unwrap(); - let mut summary = File::create("shelf/src/SUMMARY.md").unwrap(); - writeln!(summary, "# Summary")?; - writeln!(summary, "- [Index](./index.md)")?; - writeln!(index_file, "# Bookshelf")?; writeln!(index_file)?; + let mut summary_file_name = shelf_book.source_dir(); + summary_file_name.push("SUMMARY.md"); + let mut summary = File::create(summary_file_name).unwrap(); + writeln!(summary, "# Summary")?; + writeln!(summary, "- [Index](./index.md)")?; + for sb in &shelf.book { if let Some(url) = &sb.git_url { println!("{:?}", sb);