Skip to content

Commit

Permalink
feat(cli): added --yes flag for non-interactive modes for update comm…
Browse files Browse the repository at this point in the history
…and (glasskube#468)
  • Loading branch information
sumeshmurali authored and christophenne committed Apr 12, 2024
1 parent 3ee7308 commit 4e5d742
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cmd/glasskube/cmd/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (

var updateCmdOptions struct {
Version string
Yes bool
}

var updateCmd = &cobra.Command{
Expand Down Expand Up @@ -56,7 +57,7 @@ var updateCmd = &cobra.Command{

if tx != nil && !tx.IsEmpty() {
printTransaction(*tx)
if !cliutils.YesNoPrompt("Do you want to apply these updates?", false) {
if !updateCmdOptions.Yes && !cliutils.YesNoPrompt("Do you want to apply these updates?", false) {
fmt.Fprintf(os.Stderr, "⛔ Update cancelled. No changes were made.\n")
os.Exit(0)
}
Expand Down Expand Up @@ -120,5 +121,7 @@ func completeInstalledPackageNames(
func init() {
updateCmd.PersistentFlags().StringVarP(&updateCmdOptions.Version, "version", "v", "",
"update to a specific version")
updateCmd.PersistentFlags().BoolVarP(&updateCmdOptions.Yes, "yes", "y", false,
"do not ask for any confirmation")
RootCmd.AddCommand(updateCmd)
}

0 comments on commit 4e5d742

Please sign in to comment.