From d081bbaefa270e69a87f1d01d53b4044da6ad796 Mon Sep 17 00:00:00 2001 From: decentral1se Date: Mon, 21 Apr 2025 21:06:29 +0200 Subject: [PATCH] feat: auto select single server See https://git.coopcloud.tech/toolshed/organising/issues/513 --- cli/app/new.go | 6 ++++++ tests/integration/app_new.bats | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/cli/app/new.go b/cli/app/new.go index 8428b4a7..e022beed 100644 --- a/cli/app/new.go +++ b/cli/app/new.go @@ -302,6 +302,12 @@ func ensureServerFlag() error { return err } + if len(servers) == 1 { + newAppServer = servers[0] + log.Infof("single server detected, choosing %s automatically", newAppServer) + return nil + } + if newAppServer == "" && !internal.NoInput { prompt := &survey.Select{ Message: "Select app server:", diff --git a/tests/integration/app_new.bats b/tests/integration/app_new.bats index cc0283e2..06854930 100644 --- a/tests/integration/app_new.bats +++ b/tests/integration/app_new.bats @@ -250,3 +250,10 @@ teardown(){ "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env" assert_success } + +@test "automatically select single server" { + # NOTE(d1): no --no-input required, single server available + run $ABRA app new "$TEST_RECIPE" --domain "$TEST_APP_DOMAIN" + assert_success + assert_exists "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env" +}