blog 0.1.1

A CLI tool to manage blog posts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use std::fs::DirBuilder;
use std::path::PathBuf;

use log::info;

/// Creates a directory at the given path if it does not exist.
pub fn create_path(path: &PathBuf) -> Result<(), String> {
    if !path.exists() {
        info!("Creating path: {}", path.display());
        DirBuilder::new()
            .recursive(true)
            .create(path)
            .map_err(|e| format!("Failed to create directory: {e}"))?;
    }

    Ok(())
}