-
Notifications
You must be signed in to change notification settings - Fork 33
refactor: remove survey package and permanently enable huh prompts #425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
de4d0cb
5fe70e1
e84ae4f
5eab256
89bff6c
d1e7e59
4875c75
fc68e94
3d521b0
1e01d49
3286f80
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -21,11 +21,21 @@ import ( | |||||||||||||||
| "fmt" | ||||||||||||||||
| "strings" | ||||||||||||||||
|
|
||||||||||||||||
| "github.com/slackapi/slack-cli/internal/experiment" | ||||||||||||||||
| "github.com/slackapi/slack-cli/internal/slackerror" | ||||||||||||||||
| "github.com/slackapi/slack-cli/internal/style" | ||||||||||||||||
| "github.com/spf13/pflag" | ||||||||||||||||
| ) | ||||||||||||||||
|
|
||||||||||||||||
| // MimicInputPrompt formats a message and value to appear as a prompted input | ||||||||||||||||
| func MimicInputPrompt(message string, value string) string { | ||||||||||||||||
| return fmt.Sprintf( | ||||||||||||||||
| "%s %s %s", | ||||||||||||||||
| style.Darken("?"), | ||||||||||||||||
| style.Highlight(message), | ||||||||||||||||
| style.Input(value), | ||||||||||||||||
| ) | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
|
Comment on lines
+29
to
+38
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question: Why was this added? A quick search doesn't show that it's called anywhere. Since this PR is focused on removing survey, if we need to add
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. its used in @add.go
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🪓 @srtaalej This is alright to remove IIRC - it was included with survey as a placeholder output for the following command in particular:
👾 ramble: We wanted this to mimic the input form with an argument, but now that forms disappear we might be alright to remove this too: Lines 106 to 112 in 0c37128
|
||||||||||||||||
| // PromptConfig contains general information about a prompt | ||||||||||||||||
| type PromptConfig interface { | ||||||||||||||||
| GetFlags() []*pflag.Flag // GetFlags returns all flags for the prompt | ||||||||||||||||
|
|
@@ -193,28 +203,19 @@ func errInteractivityFlags(cfg PromptConfig) error { | |||||||||||||||
| // 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.Huh) { | ||||||||||||||||
| return confirmForm(io, ctx, message, defaultValue) | ||||||||||||||||
| } | ||||||||||||||||
| return surveyConfirmPrompt(io, ctx, message, defaultValue) | ||||||||||||||||
| return confirmForm(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.Huh) { | ||||||||||||||||
| return inputForm(io, ctx, message, cfg) | ||||||||||||||||
| } | ||||||||||||||||
| return surveyInputPrompt(io, ctx, message, cfg) | ||||||||||||||||
| return inputForm(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.Huh) { | ||||||||||||||||
| return multiSelectForm(io, ctx, message, options) | ||||||||||||||||
| } | ||||||||||||||||
| return surveyMultiSelectPrompt(io, ctx, message, options) | ||||||||||||||||
| return multiSelectForm(io, ctx, message, options) | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| // PasswordPrompt prompts the user with a hidden text input for the message | ||||||||||||||||
|
|
@@ -229,10 +230,7 @@ func (io *IOStreams) PasswordPrompt(ctx context.Context, message string, cfg Pas | |||||||||||||||
| return PasswordPromptResponse{}, errInteractivityFlags(cfg) | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| if io.config.WithExperimentOn(experiment.Huh) { | ||||||||||||||||
| return passwordForm(io, ctx, message, cfg) | ||||||||||||||||
| } | ||||||||||||||||
| return surveyPasswordPrompt(io, ctx, message, cfg) | ||||||||||||||||
| return passwordForm(io, ctx, message, cfg) | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| // SelectPrompt prompts the user to make a selection and returns the choice | ||||||||||||||||
|
|
@@ -257,8 +255,5 @@ func (io *IOStreams) SelectPrompt(ctx context.Context, msg string, options []str | |||||||||||||||
| } | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| if io.config.WithExperimentOn(experiment.Huh) { | ||||||||||||||||
| return selectForm(io, ctx, msg, options, cfg) | ||||||||||||||||
| } | ||||||||||||||||
| return surveySelectPrompt(io, ctx, msg, options, cfg) | ||||||||||||||||
| return selectForm(io, ctx, msg, options, cfg) | ||||||||||||||||
| } | ||||||||||||||||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👁️🗨️ question: Can this be checked within
iostreams.MatchPromptConfigor does this assert something about the orderings?