Skip to content

Commit

Permalink
Improve PathBuf usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Coi-l committed Mar 26, 2024
1 parent ba3fe43 commit 66bb88c
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/cmd/shelf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 66bb88c

Please sign in to comment.