diff options
| author | Ellie Huxtable <e@elm.sh> | 2021-03-10 21:24:08 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-10 21:24:08 +0000 |
| commit | 61607e023fbb916f376a7070f8b1ffd6ffe16849 (patch) | |
| tree | eadc28b084e0d07f6e3fd0fcaa4c74f2f840c04c /src/main.rs | |
| parent | Really annoyed me today, so bump version (diff) | |
| download | atuin-61607e023fbb916f376a7070f8b1ffd6ffe16849.zip | |
Add config file support (#15)
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/main.rs b/src/main.rs index 380df592..78e10731 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,11 +1,10 @@ -#![feature(str_split_once)] #![feature(proc_macro_hygiene)] #![feature(decl_macro)] #![warn(clippy::pedantic, clippy::nursery)] +#![allow(clippy::use_self)] // not 100% reliable use std::path::PathBuf; -use directories::ProjectDirs; use eyre::{eyre, Result}; use structopt::StructOpt; @@ -15,12 +14,17 @@ extern crate log; #[macro_use] extern crate rocket; +#[macro_use] +extern crate serde_derive; + use command::AtuinCmd; use local::database::Sqlite; +use settings::Settings; mod command; mod local; mod remote; +mod settings; #[derive(StructOpt)] #[structopt( @@ -38,6 +42,8 @@ struct Atuin { impl Atuin { fn run(self) -> Result<()> { + let settings = Settings::new()?; + let db_path = if let Some(db_path) = self.db { let path = db_path .to_str() @@ -45,17 +51,12 @@ impl Atuin { let path = shellexpand::full(path)?; PathBuf::from(path.as_ref()) } else { - ProjectDirs::from("com", "elliehuxtable", "atuin") - .ok_or_else(|| { - eyre!("could not determine db file location\nspecify one using the --db flag") - })? - .data_dir() - .join("history.db") + PathBuf::from(settings.local.db.path.as_str()) }; let mut db = Sqlite::new(db_path)?; - self.atuin.run(&mut db) + self.atuin.run(&mut db, &settings) } } |
