From 80c8a7c471e5d7bc1ad874aea2b7959c35eac137 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Wed, 26 May 2021 22:04:01 -0700 Subject: refactor(whirl): move environment setup, execute doesn't take matches --- crates/whirl/src/cli.rs | 10 ++-------- crates/whirl/src/whirl.rs | 6 +++--- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/crates/whirl/src/cli.rs b/crates/whirl/src/cli.rs index 52a1858..0f07690 100644 --- a/crates/whirl/src/cli.rs +++ b/crates/whirl/src/cli.rs @@ -1,22 +1,16 @@ // Copyleft (ɔ) 2021-2021 The Whirlsplash Collective // SPDX-License-Identifier: GPL-3.0-only -use structopt::clap::{App, AppSettings, Arg, ArgMatches, SubCommand}; +use structopt::clap::{App, AppSettings, Arg, SubCommand}; use whirl_config::Config; use crate::subs::run; pub struct Cli; impl Cli { - pub fn setup() -> ArgMatches<'static> { + pub async fn execute() -> Result<(), Box> { let matches = Self::cli().get_matches(); - std::env::set_var("DATABASE_URL", "whirl.sqlite3"); - - matches - } - - pub async fn execute(matches: ArgMatches<'_>) -> Result<(), Box> { if Config::get().whirlsplash.log.test { error!("error"); warn!("warn"); diff --git a/crates/whirl/src/whirl.rs b/crates/whirl/src/whirl.rs index 8b893f5..359a5ff 100644 --- a/crates/whirl/src/whirl.rs +++ b/crates/whirl/src/whirl.rs @@ -11,8 +11,8 @@ use crate::cli::Cli; pub struct Whirl; impl Whirl { pub async fn splash() -> Result<(), Box> { - // Environment and CLI - let matches = Cli::setup(); + // Environment + std::env::set_var("DATABASE_URL", "whirl.sqlite3"); // Logging dotenv::dotenv().ok(); @@ -34,7 +34,7 @@ impl Whirl { } } - Cli::execute(matches).await.unwrap(); + Cli::execute().await.unwrap(); Ok(()) } -- cgit v1.2.3