chiral-cli-common 0.1.2

Common Types, Traits and Structs for Chiral Command-Line-Interface
Documentation
pub mod command; 
pub mod errors;
pub mod data;
pub mod extract;
pub mod version;

pub mod utils {
    pub fn ensure_dir() -> std::io::Result<()> {
        let home_dir = chiral_common::fs::default_dir(); 
        if !home_dir.exists() {
            std::fs::create_dir(home_dir)?;
        }

        let reports_dir = get_reports_dir();
        if !reports_dir.exists() {
            std::fs::create_dir(reports_dir)?;
        }

        Ok(())
    }
    pub fn get_filepath(filename: &str) -> std::path::PathBuf {
        chiral_common::fs::default_dir().join(filename)
    }

    pub fn get_history_filepath() -> std::path::PathBuf {
        chiral_common::fs::default_dir().join("history.txt")
    }

    pub fn get_reports_dir() -> std::path::PathBuf {
        chiral_common::fs::default_dir().join("reports")
    }

    pub fn get_report_files() -> std::fs::ReadDir {
        std::fs::read_dir(get_reports_dir()).unwrap()
    }

    pub fn get_report_filepath(job_id: &str) -> std::path::PathBuf {
        let filename = format!("{job_id}.txt");
        get_reports_dir().join(filename)
    }

    pub fn get_report_filepath_with_timestamp(job_id: &str) -> std::path::PathBuf {
        let time_str = chrono::Utc::now().to_string();
        let filename = format!("{job_id} {time_str}.txt");
        get_reports_dir().join(filename)
    }
    
    pub fn get_jobs_filepath() -> std::path::PathBuf {
        chiral_common::fs::default_dir().join("jobs.txt")
    }
}