Add --force/-f flag to gt shutdown to skip confirmation prompt
This commit is contained in:
@@ -24,6 +24,7 @@ var (
|
|||||||
shutdownGraceful bool
|
shutdownGraceful bool
|
||||||
shutdownWait int
|
shutdownWait int
|
||||||
shutdownAll bool
|
shutdownAll bool
|
||||||
|
shutdownForce bool
|
||||||
shutdownYes bool
|
shutdownYes bool
|
||||||
shutdownPolecatsOnly bool
|
shutdownPolecatsOnly bool
|
||||||
shutdownNuclear bool
|
shutdownNuclear bool
|
||||||
@@ -62,8 +63,8 @@ Shutdown levels (progressively more aggressive):
|
|||||||
--all - Also stop crew sessions
|
--all - Also stop crew sessions
|
||||||
--polecats-only - Only stop polecats (leaves everything else running)
|
--polecats-only - Only stop polecats (leaves everything else running)
|
||||||
|
|
||||||
|
Use --force or --yes to skip confirmation prompt.
|
||||||
Use --graceful to allow agents time to save state before killing.
|
Use --graceful to allow agents time to save state before killing.
|
||||||
Use --yes to skip confirmation prompt.
|
|
||||||
Use --nuclear to force cleanup even if polecats have uncommitted work (DANGER).`,
|
Use --nuclear to force cleanup even if polecats have uncommitted work (DANGER).`,
|
||||||
RunE: runShutdown,
|
RunE: runShutdown,
|
||||||
}
|
}
|
||||||
@@ -78,6 +79,8 @@ func init() {
|
|||||||
"Seconds to wait for graceful shutdown (default 30)")
|
"Seconds to wait for graceful shutdown (default 30)")
|
||||||
shutdownCmd.Flags().BoolVarP(&shutdownAll, "all", "a", false,
|
shutdownCmd.Flags().BoolVarP(&shutdownAll, "all", "a", false,
|
||||||
"Also stop crew sessions (by default, crew is preserved)")
|
"Also stop crew sessions (by default, crew is preserved)")
|
||||||
|
shutdownCmd.Flags().BoolVarP(&shutdownForce, "force", "f", false,
|
||||||
|
"Skip confirmation prompt (alias for --yes)")
|
||||||
shutdownCmd.Flags().BoolVarP(&shutdownYes, "yes", "y", false,
|
shutdownCmd.Flags().BoolVarP(&shutdownYes, "yes", "y", false,
|
||||||
"Skip confirmation prompt")
|
"Skip confirmation prompt")
|
||||||
shutdownCmd.Flags().BoolVar(&shutdownPolecatsOnly, "polecats-only", false,
|
shutdownCmd.Flags().BoolVar(&shutdownPolecatsOnly, "polecats-only", false,
|
||||||
@@ -279,7 +282,7 @@ func runShutdown(cmd *cobra.Command, args []string) error {
|
|||||||
fmt.Println()
|
fmt.Println()
|
||||||
|
|
||||||
// Confirmation prompt
|
// Confirmation prompt
|
||||||
if !shutdownYes {
|
if !shutdownYes && !shutdownForce {
|
||||||
fmt.Printf("Proceed with shutdown? [y/N] ")
|
fmt.Printf("Proceed with shutdown? [y/N] ")
|
||||||
reader := bufio.NewReader(os.Stdin)
|
reader := bufio.NewReader(os.Stdin)
|
||||||
response, _ := reader.ReadString('\n')
|
response, _ := reader.ReadString('\n')
|
||||||
@@ -327,7 +330,7 @@ func categorizeSessions(sessions []string) (toStop, preserved []string) {
|
|||||||
preserved = append(preserved, sess)
|
preserved = append(preserved, sess)
|
||||||
}
|
}
|
||||||
} else if shutdownAll {
|
} else if shutdownAll {
|
||||||
// Stop everything
|
// Stop everything including crew
|
||||||
toStop = append(toStop, sess)
|
toStop = append(toStop, sess)
|
||||||
} else {
|
} else {
|
||||||
// Default: preserve crew
|
// Default: preserve crew
|
||||||
|
|||||||
Reference in New Issue
Block a user