aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2021-05-26 22:04:01 -0700
committerFuwn <[email protected]>2021-05-26 22:04:01 -0700
commit80c8a7c471e5d7bc1ad874aea2b7959c35eac137 (patch)
tree6817e3cadad6b32e07db1197831aa4aac35d0a00
parentrefactor(cli): restructure subcommand matching, removes shell completions sub... (diff)
downloadwhirl-80c8a7c471e5d7bc1ad874aea2b7959c35eac137.tar.xz
whirl-80c8a7c471e5d7bc1ad874aea2b7959c35eac137.zip
refactor(whirl): move environment setup, execute doesn't take matches
-rw-r--r--crates/whirl/src/cli.rs10
-rw-r--r--crates/whirl/src/whirl.rs6
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<dyn std::error::Error>> {
let matches = Self::cli().get_matches();
- std::env::set_var("DATABASE_URL", "whirl.sqlite3");
-
- matches
- }
-
- pub async fn execute(matches: ArgMatches<'_>) -> Result<(), Box<dyn std::error::Error>> {
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<dyn Error>> {
- // 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(())
}