Archived
1

working on CLI interface

This commit is contained in:
Evan Pratten 2022-01-23 13:35:49 -05:00
parent ebc174984c
commit 552513e3ce

26
src/config.rs Normal file
View File

@ -0,0 +1,26 @@
use std::path::PathBuf;
use colored::Colorize;
use directories::ProjectDirs;
pub fn get_config_dir() -> Result<PathBuf, ()> {
// Construct the path to the config directory for this app
let project_dir = ProjectDirs::from("com", "va3zza", "tabset");
// Only pass back the directory if it exists
match project_dir {
Some(dir) => {
let config_dir = dir.config_dir();
if config_dir.exists() {
Ok(config_dir.to_path_buf())
} else {
eprintln!("{}\nPlease create: {}\nConfiguration info can be found at: ",
"tabset requires configuration files to be placed in its config directory.\nThis does not exist.".red(),
config_dir.display()
);
Err(())
}
}
None => Err(()),
}
}