bookyard 0.1.0

Build and locally edit a bookshelf for multiple mdBook projects.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use anyhow::{Context, bail};
use bookyard_core::BookyardConfig;

pub fn run(title: &str, force: bool) -> anyhow::Result<()> {
    let path = crate::commands::config_path()?;
    if path.exists() && !force {
        bail!(
            "{} already exists; pass --force to replace it",
            path.display()
        );
    }
    let config = BookyardConfig::new(title);
    config
        .save_to(&path)
        .with_context(|| format!("failed to write {}", path.display()))?;
    println!("created {}", path.display());
    Ok(())
}