mps-rs 1.1.0

MPS — plain-text personal productivity CLI (Rust)
Documentation
use anyhow::{Context, Result};
use chrono::NaiveDate;
use crate::config::Config;
use crate::store::Store;

pub fn run(config: &Config, date: NaiveDate) -> Result<()> {
    let store = Store::new(&config.storage_dir);
    let path  = store.find_or_create_path(date);

    let editor = std::env::var("EDITOR")
        .or_else(|_| std::env::var("VISUAL"))
        .unwrap_or_else(|_| "vim".to_string());

    std::process::Command::new(&editor)
        .arg(&path)
        .status()
        .with_context(|| format!("failed to launch editor '{}'", editor))?;

    Ok(())
}