Skip to content
Myr

feat(confirm): add `--show-output` (#427)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* feat(confirm): add `--show-output` * feat(confirm): add `--show-output` model ---------

authored by vahnrr · committed by GitHub · parent 74c1079 · Browse files · 3 files+11 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Co-authored-by: vahnrr <vahnrr@pm.me>

Diff stats

3 files+11 added−0 removed

  • other:+11 added−0 removed

3 files+11 added−0 removed

modified:confirm/command.go+9 added
17 unmodified lines
1819 m := model{20 affirmative: o.Affirmative,21 negative: o.Negative,22 showOutput: o.ShowOutput,23 confirmation: o.Default,24 defaultSelection: o.Default,25 keys: defaultKeymap(o.Affirmative, o.Negative),26 help: help.New(),
11 unmodified lines
38 if err != nil {39 return fmt.Errorf("unable to confirm: %w", err)40 }4142 if o.ShowOutput {43 confirmationText := m.negative44 if m.confirmation {45 confirmationText = m.affirmative46 }47 fmt.Println(m.prompt, confirmationText)48 }4950 m = tm.(model)51 if m.confirmation {52 return nil53 }
3 unmodified lines
modified:confirm/confirm.go+1 added
80 unmodified lines
81 showHelp bool82 help help.Model83 keys keymap8485 showOutput bool86 confirmation bool8788 defaultSelection bool89
77 unmodified lines
modified:confirm/options.go+1 added
7 unmodified lines
89// Options is the customization options for the confirm command.10type Options struct {11 Default bool `help:"Default confirmation action" default:"true"`12 ShowOutput bool `help:"Print prompt and chosen action to output" default:"false"`13 Affirmative string `help:"The title of the affirmative action" default:"Yes"`14 Negative string `help:"The title of the negative action" default:"No"`15 Prompt string `arg:"" help:"Prompt to display." default:"Are you sure?"`16 //nolint:staticcheck
8 unmodified lines