1// SPDX-FileCopyrightText: Amolith <amolith@secluded.site>
2//
3// SPDX-License-Identifier: AGPL-3.0-or-later
4
5package ui
6
7import "github.com/charmbracelet/huh"
8
9// Confirm asks the user to confirm an action using an interactive prompt.
10// Returns false on cancellation or error (fail closed).
11func Confirm(title string) bool {
12 var confirmed bool
13
14 err := huh.NewConfirm().
15 Title(title).
16 Affirmative("Yes").
17 Negative("No").
18 Inline(true).
19 Value(&confirmed).
20 Run()
21 if err != nil {
22 return false
23 }
24
25 return confirmed
26}