Skip to content

Commit

Permalink
skip confirmation (#516)
Browse files Browse the repository at this point in the history
  • Loading branch information
czarcas7ic authored Feb 7, 2024
1 parent 97b06aa commit e95dddd
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -654,15 +654,20 @@ 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
}
}

serverCtx.Viper.Set(KeyIsTestnet, true)
serverCtx.Viper.Set(KeyNewChainID, newChainID)
serverCtx.Viper.Set(KeyNewOpAddr, newOperatorAddress)
Expand All @@ -673,6 +678,7 @@ you want to test the upgrade handler itself.

addStartNodeFlags(cmd, defaultNodeHome)
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 e95dddd

Please sign in to comment.