Skip to content
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

Update init experience #3933

Merged
merged 4 commits into from
Sep 27, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Auto formatting
  • Loading branch information
AaronCrawfis committed Sep 27, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit a292c369b617305a49c735a3dafd75f3f7ee0a52
13 changes: 7 additions & 6 deletions pkg/cli/prompt/prompt.go
Original file line number Diff line number Diff line change
@@ -166,16 +166,16 @@ func (i *Impl) RunPrompt(prompter promptui.Prompt) (string, error) {
return prompter.Run()
}

//Prompts user to select from a list of values
// Prompts user to select from a list of values
func (i *Impl) RunSelect(selector promptui.Select) (int, string, error) {
return selector.Run()
}

// Creates a Yes or No prompts where user has to enter either a Y or N as input
func YesOrNoPrompter(label string, defaultValue string, prompter Interface) (string, error) {
textPrompt := promptui.Prompt{
Label: label,
Default: defaultValue,
Label: label,
Default: defaultValue,
Validate: validateYesOrNo,
}
result, err := prompter.RunPrompt(textPrompt)
@@ -197,8 +197,8 @@ func validateYesOrNo(s string) error {
// Creates a prompt where a user is asked for a value suggesting a default Val
func TextPromptWithDefault(label string, defaultVal string, f func(s string) (bool, string, error)) promptui.Prompt {
return promptui.Prompt{
Label: label,
Default: defaultVal,
Label: label,
Default: defaultVal,
Validate: func(s string) error {
valid, msg, err := f(s)
if err != nil {
@@ -209,6 +209,7 @@ func TextPromptWithDefault(label string, defaultVal string, f func(s string) (bo
}
return nil
},
AllowEdit: true,
}
}

@@ -218,7 +219,7 @@ func SelectionPrompter(label string, items []string) promptui.Select {
Label: label,
Items: items,
Searcher: func(input string, index int) bool {
return strings.HasPrefix(items[index],input)
return strings.HasPrefix(items[index], input)
},
}
}