refactor(experiment): separate iostreams prompts from survey implementations#404
refactor(experiment): separate iostreams prompts from survey implementations#404
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #404 +/- ##
==========================================
+ Coverage 67.90% 68.19% +0.29%
==========================================
Files 218 219 +1
Lines 18050 18055 +5
==========================================
+ Hits 12256 12312 +56
+ Misses 4640 4587 -53
- Partials 1154 1156 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
zimeg
left a comment
There was a problem hiding this comment.
🔏 A few more notes on changes more!
🍀 I realize the reason to separate prompt interfaces from implementations wasn't noted in the description, but these changes hope to keep interfaces stable as the charm experiment reaches conclusion.
| }, nil) | ||
| cm.IO.On("InputPrompt", mock.Anything, "Enter an expression", iostreams.InputPromptConfig{ | ||
| Required: false, | ||
| }).Return("") |
There was a problem hiding this comment.
🧪 note: Lots of changes add the expected error value to mock prompts!
| if cfg.PageSize > 0 { | ||
| field.Height(cfg.PageSize + 2) | ||
| } |
| // ConfirmPrompt prompts the user for a "yes" or "no" (true or false) value for | ||
| // the message | ||
| func (io *IOStreams) ConfirmPrompt(ctx context.Context, message string, defaultValue bool) (bool, error) { | ||
| if io.config.WithExperimentOn(experiment.Charm) { | ||
| return charmConfirmPrompt(io, ctx, message, defaultValue) | ||
| } | ||
| return surveyConfirmPrompt(io, ctx, message, defaultValue) | ||
| } | ||
|
|
||
| // InputPrompt prompts the user for a string value for the message, which can | ||
| // optionally be made required | ||
| func (io *IOStreams) InputPrompt(ctx context.Context, message string, cfg InputPromptConfig) (string, error) { | ||
| if io.config.WithExperimentOn(experiment.Charm) { | ||
| return charmInputPrompt(io, ctx, message, cfg) | ||
| } | ||
| return surveyInputPrompt(io, ctx, message, cfg) | ||
| } | ||
|
|
||
| // MultiSelectPrompt prompts the user to select multiple values in a list and | ||
| // returns the selected values | ||
| func (io *IOStreams) MultiSelectPrompt(ctx context.Context, message string, options []string) ([]string, error) { | ||
| if io.config.WithExperimentOn(experiment.Charm) { | ||
| return charmMultiSelectPrompt(io, ctx, message, options) | ||
| } | ||
| return surveyMultiSelectPrompt(io, ctx, message, options) | ||
| } |
There was a problem hiding this comment.
👾 note: IIRC callsites often guard against flag inputs, but we might follow up with changes here to accept these in configurations so these prompts guard against scripting fallthrough!
🐌 ramble: I'm curious about the default behavior for confirm prompts too when interactive prompts aren't available since we might use the default choice instead of requiring flag alternatives to perhaps revisit the changes of #87?
Changelog
Summary
This PR separates
iostreamsprompts fromsurveyimplementations for improvements to test cases and planned changes toward standard flag handling.Reviewers
No change to logic with this change I hope!
Requirements