From 058e5e336e655497d207b4eb27b49e649a5075ad Mon Sep 17 00:00:00 2001 From: David Barroso Date: Fri, 13 Oct 2023 09:54:24 +0200 Subject: [PATCH] feat: added --yes flag to config pull to skip confirmation --- cmd/config/pull.go | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/cmd/config/pull.go b/cmd/config/pull.go index 9caca4fc0..39eab3734 100644 --- a/cmd/config/pull.go +++ b/cmd/config/pull.go @@ -22,6 +22,10 @@ const ( DefaultNhostWebhookSecret = "nhost-webhook-secret" //nolint:gosec ) +const ( + flagYes = "yes" +) + func CommandPull() *cli.Command { return &cli.Command{ //nolint:exhaustruct Name: "pull", @@ -34,6 +38,11 @@ func CommandPull() *cli.Command { Usage: "Pull this subdomain's configuration. Defaults to linked project", EnvVars: []string{"NHOST_SUBDOMAIN"}, }, + &cli.BoolFlag{ //nolint:exhaustruct + Name: flagYes, + Usage: "Skip confirmation", + EnvVars: []string{"NHOST_YES"}, + }, }, } } @@ -41,13 +50,19 @@ func CommandPull() *cli.Command { func commandPull(cCtx *cli.Context) error { ce := clienv.FromCLI(cCtx) - if err := verifyFile(ce, ce.Path.NhostToml()); err != nil { - return err + skipConfirmation := cCtx.Bool(flagYes) + + if !skipConfirmation { + if err := verifyFile(ce, ce.Path.NhostToml()); err != nil { + return err + } } writeSecrets := true - if err := verifyFile(ce, ce.Path.Secrets()); err != nil { - writeSecrets = false + if !skipConfirmation { + if err := verifyFile(ce, ce.Path.Secrets()); err != nil { + writeSecrets = false + } } proj, err := ce.GetAppInfo(cCtx.Context, cCtx.String(flagSubdomain))