summaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorMatthias Beyer <matthias.beyer@atos.net>2021-04-27 09:20:39 +0200
committerMatthias Beyer <mail@beyermatthias.de>2021-05-11 11:20:52 +0200
commitb286e4d5cfeba9e388197b7afd1fc12b20631609 (patch)
tree22d93b9d68c761f4efaaf2b3364c0cd1b43544c0 /src/main.rs
parentda98e8507857c6cc1a94cdc909b7e5fdb993bf0f (diff)
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 <matthias.beyer@atos.net>
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs8
1 files changed, 4 insertions, 4 deletions
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")?