mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 11:03:34 +00:00
chore: style the machine reset prompt in red and fix the padding for [y/N]
This commit is contained in:
@@ -106,21 +106,21 @@ func promptResetMachine() error {
|
|||||||
"use --yes flag or set UNCLOUD_AUTO_CONFIRM=true to auto-confirm")
|
"use --yes flag or set UNCLOUD_AUTO_CONFIRM=true to auto-confirm")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fmt.Println(tui.Red.Render("The remote machine is already initialised as a cluster member. Resetting it will:\n" +
|
||||||
|
"- Remove all service containers from the machine\n" +
|
||||||
|
"- Reset the machine to the uninitialised state"))
|
||||||
|
|
||||||
var confirm bool
|
var confirm bool
|
||||||
form := huh.NewForm(
|
form := huh.NewForm(
|
||||||
huh.NewGroup(
|
huh.NewGroup(
|
||||||
huh.NewConfirm().
|
huh.NewConfirm().
|
||||||
Title(
|
Title("Do you want to reset it first?").
|
||||||
"The remote machine is already initialised as a cluster member. Do you want to reset it first?\n" +
|
|
||||||
"This will:\n" +
|
|
||||||
"- Remove all service containers from the machine\n" +
|
|
||||||
"- Reset the machine to the uninitialised state",
|
|
||||||
).
|
|
||||||
Affirmative("Yes!").
|
Affirmative("Yes!").
|
||||||
Negative("No").
|
Negative("No").
|
||||||
Value(&confirm),
|
Value(&confirm),
|
||||||
),
|
),
|
||||||
).WithAccessible(true)
|
).WithTheme(tui.ThemeConfirmDanger()).
|
||||||
|
WithAccessible(true)
|
||||||
if err := form.Run(); err != nil {
|
if err := form.Run(); err != nil {
|
||||||
return fmt.Errorf("prompt user to confirm: %w", err)
|
return fmt.Errorf("prompt user to confirm: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,15 @@ func ThemeConfirm() huh.Theme {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ThemeConfirmDanger returns a huh theme with a bold red title style for dangerous confirmation prompts.
|
||||||
|
func ThemeConfirmDanger() huh.Theme {
|
||||||
|
return huh.ThemeFunc(func(isDark bool) *huh.Styles {
|
||||||
|
t := huh.ThemeBase(isDark)
|
||||||
|
t.Focused.Title = t.Focused.Title.Foreground(lipgloss.Red).Bold(true)
|
||||||
|
return t
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// IsStdinTerminal checks if the standard input is a terminal (TTY).
|
// IsStdinTerminal checks if the standard input is a terminal (TTY).
|
||||||
func IsStdinTerminal() bool {
|
func IsStdinTerminal() bool {
|
||||||
return term.IsTerminal(int(os.Stdin.Fd()))
|
return term.IsTerminal(int(os.Stdin.Fd()))
|
||||||
|
|||||||
Reference in New Issue
Block a user