Skip to content

Commit

Permalink
adds a skip-confirmation flag
Browse files Browse the repository at this point in the history
  • Loading branch information
czarcas7ic committed Feb 7, 2024
1 parent 56f6542 commit 4e191a1
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -667,14 +667,18 @@ you want to test the upgrade handler itself.
newChainID := args[0]
newOperatorAddress := args[1]

// Confirmation prompt to prevent accidental modification of state.
reader := bufio.NewReader(os.Stdin)
fmt.Println("This operation will modify state in your data folder and cannot be undone. Do you want to continue? (y/n)")
text, _ := reader.ReadString('\n')
response := strings.TrimSpace(strings.ToLower(text))
if response != "y" && response != "yes" {
fmt.Println("Operation canceled.")
return nil
skipConfirmation, _ := cmd.Flags().GetBool("skip-confirmation")

if !skipConfirmation {
// Confirmation prompt to prevent accidental modification of state.
reader := bufio.NewReader(os.Stdin)
fmt.Println("This operation will modify state in your data folder and cannot be undone. Do you want to continue? (y/n)")
text, _ := reader.ReadString('\n')
response := strings.TrimSpace(strings.ToLower(text))
if response != "y" && response != "yes" {
fmt.Println("Operation canceled.")
return nil
}
}

// Set testnet keys to be used by the application.
Expand All @@ -701,6 +705,7 @@ you want to test the upgrade handler itself.

addStartNodeFlags(cmd, opts)
cmd.Flags().String(KeyTriggerTestnetUpgrade, "", "If set (example: \"v21\"), triggers the v21 upgrade handler to run on the first block of the testnet")
cmd.Flags().Bool("skip-confirmation", false, "Skip the confirmation prompt")
return cmd
}

Expand Down

0 comments on commit 4e191a1

Please sign in to comment.