From 7b554cd703d3e2eee96a62709548cd551836c696 Mon Sep 17 00:00:00 2001 From: Pasha Sviderski Date: Wed, 22 Apr 2026 18:56:52 +1000 Subject: [PATCH] chore: style the machine reset prompt in red and fix the padding for [y/N] --- internal/cli/machine.go | 14 +++++++------- internal/cli/tui/prompt.go | 9 +++++++++ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/internal/cli/machine.go b/internal/cli/machine.go index 1a2851c4..3eacbfc0 100644 --- a/internal/cli/machine.go +++ b/internal/cli/machine.go @@ -106,21 +106,21 @@ func promptResetMachine() error { "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 form := huh.NewForm( huh.NewGroup( huh.NewConfirm(). - Title( - "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", - ). + Title("Do you want to reset it first?"). Affirmative("Yes!"). Negative("No"). Value(&confirm), ), - ).WithAccessible(true) + ).WithTheme(tui.ThemeConfirmDanger()). + WithAccessible(true) if err := form.Run(); err != nil { return fmt.Errorf("prompt user to confirm: %w", err) } diff --git a/internal/cli/tui/prompt.go b/internal/cli/tui/prompt.go index 865bcc62..cab3af9a 100644 --- a/internal/cli/tui/prompt.go +++ b/internal/cli/tui/prompt.go @@ -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). func IsStdinTerminal() bool { return term.IsTerminal(int(os.Stdin.Fd()))