diff --git a/src/bin/idcoop.rs b/src/bin/idcoop.rs index 582902c..d02a75d 100644 --- a/src/bin/idcoop.rs +++ b/src/bin/idcoop.rs @@ -103,9 +103,14 @@ async fn main() -> eyre::Result<()> { .await .context("Failed to connect to Postgres")?; let secrets = SecretConfig::try_new(&config).await?; - web::serve(bind, Arc::new(store), Arc::new(config), Arc::new(secrets)).await? + web::serve(bind, Arc::new(store), Arc::new(config), Arc::new(secrets)).await?; + } + Subcommand::User { cmd } => { + let store = IdCoopStore::connect(&config.postgres.connect) + .await + .context("Failed to connect to Postgres")?; + handle_user_command(cmd, &config, &store).await?; } - Subcommand::User { cmd } => handle_user_command(cmd, &config).await?, } Ok(()) diff --git a/src/cli.rs b/src/cli.rs index 35e1880..9d460c3 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -57,10 +57,11 @@ pub enum UserCommand { } /// Handles a user command from the command-line interface. -pub async fn handle_user_command(command: UserCommand, config: &Configuration) -> eyre::Result<()> { - let store = IdCoopStore::connect(&config.postgres.connect) - .await - .context("Failed to connect to Postgres")?; +pub async fn handle_user_command( + command: UserCommand, + config: &Configuration, + store: &IdCoopStore, +) -> eyre::Result<()> { match command { UserCommand::Add { username, locked } => { store