mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 11:01:25 +01:00
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:
31 files changed
+131
-253
No files matched your search
@@ -54,9 +54,9 @@ func (a *application) editDraft(cmd *cobra.Command, body string) (terminal.Draft
|
||||
// already given is never lost to a missing editor.
|
||||
func (a *application) bodyEditor(cmd *cobra.Command) terminal.BodyEditor {
|
||||
preferences, err := a.preferences()
|
||||
if asker, ok := a.deps.Prompter.(terminal.Asker); ok && err == nil && preferences.Editor == "" {
|
||||
if err == nil && preferences.Editor == "" {
|
||||
return func(ctx context.Context, initial string) (terminal.Draft, error) {
|
||||
body, err := asker.AskText(ctx, terminal.BodyTitle, initial)
|
||||
body, err := a.deps.Prompter.AskText(ctx, terminal.BodyTitle, initial)
|
||||
return terminal.Draft{Body: body}, err
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user