From b286e4d5cfeba9e388197b7afd1fc12b20631609 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 27 Apr 2021 09:20:39 +0200 Subject: Refactor: Parsing and connection establishing should be member functions This refactors the parsing of the `DbConnectionConfig` object and the establishing of the connection to be member functions of the type, rather than free functions. Way more idomatic. Signed-off-by: Matthias Beyer --- src/main.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 69dd0fa..7feb99b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -146,7 +146,7 @@ async fn main() -> Result<()> { Ok(repo) }; - let db_connection_config = crate::db::parse_db_connection_config(&config, &cli)?; + let db_connection_config = crate::db::DbConnectionConfig::parse(&config, &cli)?; match cli.subcommand() { Some(("generate-completions", matches)) => generate_completions(matches), Some(("db", matches)) => { @@ -154,7 +154,7 @@ async fn main() -> Result<()> { crate::commands::db(db_connection_config, &config, matches)? }, Some(("build", matches)) => { - let conn = crate::db::establish_connection(db_connection_config)?; + let conn = db_connection_config.establish_connection()?; let repo = load_repo()?; @@ -205,7 +205,7 @@ async fn main() -> Result<()> { Some(("find-artifact", matches)) => { let repo = load_repo()?; setup_pager(); - let conn = crate::db::establish_connection(db_connection_config)?; + let conn = db_connection_config.establish_connection()?; crate::commands::find_artifact(matches, &config, progressbars, repo, conn) .await .context("find-artifact command failed")? @@ -252,7 +252,7 @@ async fn main() -> Result<()> { Some(("metrics", _)) => { let repo = load_repo()?; setup_pager(); - let conn = crate::db::establish_connection(db_connection_config)?; + let conn = db_connection_config.establish_connection()?; crate::commands::metrics(&repo_path, &config, repo, conn) .await .context("metrics command failed")? -- cgit v1.2.3