injm 0.7.0

A CLI tool that injects content into marked regions in source files.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use std::{fs, path::PathBuf};

use crate::config::{ConfigError, GlobalConfig, Result};

pub(crate) fn load_config(config_path: Option<PathBuf>) -> Result<GlobalConfig> {
    let Some(path) = config_path else {
        return Ok(GlobalConfig::default());
    };

    if !fs::exists(&path)? {
        return Err(ConfigError::ConfigFileNotExists { path });
    }

    let content = fs::read_to_string(path)?;
    Ok(toml::from_str(&content)?)
}