refactor(prompts): fold Asker into Prompter and share delete confirmations

FormPrompter is the only production prompter and implements the rich
prompt API, so Ask, AskText and ConfirmDefault become the Prompter
interface and the plain Input/Confirm fallbacks go away.

Confirmations that default to no derive their non-terminal wording
from the prompt, and single deletes share deleteConfirmed for the
prompt, the request and the done line.

Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
bircni committed 2026-10-12 10:47:54 +02:00
1 parent 6b204a34c0
commit 1f4b5f868f
31 files changed
+131 -253

No files matched your search

+4 -10
View File
@@ -459,12 +459,12 @@ $ tea team delete 7 --yes`,
if team.Organization != "" {
subject += " from " + team.Organization
}
confirmation := terminal.Confirmation{Prompt: "Delete " + subject + "?", NonTTY: "delete " + subject}
confirmation := terminal.Confirmation{Prompt: "Delete " + subject + "?"}
if team.Permission == "owner" {
if !force {
return clierr.Wrap(clierr.Usage, fmt.Errorf("%s is the organization's owner team and its members would lose owner access; pass --force to delete it", subject))
}
confirmation = terminal.Confirmation{Prompt: "Delete owner " + subject + "? Its members lose owner access.", Typed: team.Slug(), NonTTY: "delete owner " + subject}
confirmation = terminal.Confirmation{Prompt: "Delete owner " + subject + "? Its members lose owner access.", Typed: team.Slug()}
}
if err := a.confirmAction(cmd, confirmation); err != nil {
return err
@@ -556,10 +556,7 @@ $ tea team member add 2 bob carol`,
return err
}
members := args[1:]
if err := a.confirmAction(cmd, terminal.Confirmation{
Prompt: fmt.Sprintf("Remove %s from team %s?", joinNames(members), team.Slug()),
NonTTY: fmt.Sprintf("remove %s from team %s", joinNames(members), team.Slug()),
}); err != nil {
if err := a.confirmAction(cmd, terminal.Confirmation{Prompt: fmt.Sprintf("Remove %s from team %s?", joinNames(members), team.Slug())}); err != nil {
return err
}
for _, username := range members {
@@ -661,10 +658,7 @@ repositories of other owners cannot be granted to a team.`,
repos = append(repos, repo)
}
if !grant {
if err := a.confirmAction(cmd, terminal.Confirmation{
Prompt: fmt.Sprintf("Revoke team %s access to %s?", team.Slug(), joinNames(repos)),
NonTTY: fmt.Sprintf("revoke team %s access to %s", team.Slug(), joinNames(repos)),
}); err != nil {
if err := a.confirmAction(cmd, terminal.Confirmation{Prompt: fmt.Sprintf("Revoke team %s access to %s?", team.Slug(), joinNames(repos))}); err != nil {
return err
}
}