diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 39 |
1 files changed, 4 insertions, 35 deletions
diff --git a/src/main.rs b/src/main.rs index 0045a943..c116d1f3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,29 +1,16 @@ #![warn(clippy::pedantic, clippy::nursery)] #![allow(clippy::use_self)] // not 100% reliable -use std::path::PathBuf; - -use eyre::{eyre, Result}; +use eyre::Result; use fern::colors::{Color, ColoredLevelConfig}; -use human_panic::setup_panic; use structopt::{clap::AppSettings, StructOpt}; #[macro_use] extern crate log; -#[macro_use] -extern crate serde_derive; - use command::AtuinCmd; -use local::database::Sqlite; -use settings::Settings; -mod api; mod command; -mod local; -mod server; -mod settings; -mod utils; #[derive(StructOpt)] #[structopt( @@ -33,28 +20,13 @@ mod utils; global_settings(&[AppSettings::ColoredHelp, AppSettings::DeriveDisplayOrder]) )] struct Atuin { - #[structopt(long, parse(from_os_str), help = "db file path")] - db: Option<PathBuf>, - #[structopt(subcommand)] atuin: AtuinCmd, } impl Atuin { - async fn run(self, settings: &Settings) -> Result<()> { - let db_path = if let Some(db_path) = self.db { - let path = db_path - .to_str() - .ok_or_else(|| eyre!("path {:?} was not valid UTF-8", db_path))?; - let path = shellexpand::full(path)?; - PathBuf::from(path.as_ref()) - } else { - PathBuf::from(settings.local.db_path.as_str()) - }; - - let mut db = Sqlite::new(db_path)?; - - self.atuin.run(&mut db, settings).await + async fn run(self) -> Result<()> { + self.atuin.run().await } } @@ -78,8 +50,5 @@ async fn main() -> Result<()> { .chain(std::io::stdout()) .apply()?; - let settings = Settings::new()?; - setup_panic!(); - - Atuin::from_args().run(&settings).await + Atuin::from_args().run().await } |