feat: adds info command to show env vars and config files (#1841)

* feat: adds info command to show env vars and config files

* fix: clippy

* refactor: clippy and format again
This commit is contained in:
YummyOreo 2024-03-10 12:31:35 -05:00 committed by GitHub
parent a3c3dad900
commit ba0fe21795
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 41 additions and 0 deletions

View File

@ -17,6 +17,7 @@ mod doctor;
mod dotfiles;
mod history;
mod import;
mod info;
mod init;
mod kv;
mod search;
@ -59,6 +60,10 @@ pub enum Cmd {
#[command()]
Init(init::Cmd),
/// Information about dotfiles locations and ENV vars
#[command()]
Info,
#[command()]
Doctor,
@ -117,6 +122,11 @@ impl Cmd {
Self::Init(init) => init.run(&settings).await,
Self::Info => {
info::run(&settings);
Ok(())
}
Self::Doctor => doctor::run(&settings),
Self::DefaultConfig => {

View File

@ -0,0 +1,31 @@
use atuin_client::settings::Settings;
use crate::VERSION;
pub fn run(settings: &Settings) {
let config = atuin_common::utils::config_dir();
let mut config_file = config.clone();
config_file.push("config.toml");
let mut sever_config = config;
sever_config.push("server.toml");
let config_paths = format!(
"Config files:\nclient config: {:?}\nserver config: {:?}\nclient db path: {:?}\nkey path: {:?}\nsession path: {:?}",
config_file.to_string_lossy(),
sever_config.to_string_lossy(),
settings.db_path,
settings.key_path,
settings.session_path
);
let env_vars = format!(
"Env Vars:\nATUIN_CONFIG_DIR = {:?}",
std::env::var("ATUIN_CONFIG_DIR").unwrap_or_else(|_| "None".into())
);
let general_info = format!("Version info:\nversion: {VERSION}");
let print_out = format!("{config_paths}\n\n{env_vars}\n\n{general_info}");
println!("{print_out}");
}