-
Notifications
You must be signed in to change notification settings - Fork 100
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
Update init experience #3933
Changes from all commits
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 |
---|---|---|
|
@@ -38,8 +38,7 @@ func SelectEnvironmentName(cmd *cobra.Command, defaultVal string, interactive bo | |
return "", err | ||
} | ||
if interactive && envStr == "" { | ||
promptMsg := fmt.Sprintf("Enter an environment name [%s]:", defaultVal) | ||
envStr, err = prompter.RunPrompt(prompt.TextPromptWithDefault(promptMsg, defaultVal, prompt.ResourceName)) | ||
envStr, err = prompter.RunPrompt(prompt.TextPromptWithDefault("Enter an environment name", defaultVal, prompt.ResourceName)) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
@@ -62,9 +61,8 @@ func SelectNamespace(cmd *cobra.Command, defaultVal string, interactive bool, pr | |
var val string | ||
var err error | ||
if interactive { | ||
promptMsg := fmt.Sprintf("Enter a namespace name to deploy apps into [%s]:", defaultVal) | ||
namespaceSelector := promptui.Prompt { | ||
Label: promptMsg, | ||
namespaceSelector := promptui.Prompt{ | ||
Label: "Enter a namespace name to deploy apps into", | ||
Default: defaultVal, | ||
Validate: func(s string) error { | ||
valid, msg, err := prompt.EmptyValidator(s) | ||
|
@@ -76,6 +74,7 @@ func SelectNamespace(cmd *cobra.Command, defaultVal string, interactive bool, pr | |
} | ||
return nil | ||
}, | ||
AllowEdit: true, | ||
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. This places the cursor at the end of the line instead of the beginning 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. In the other case, the user can either press enter or start typing. In this case the user will have to clear the default first? 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. 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. As an alternative we can switch to https://github.com/charmbracelet/bubbletea, which has better support for default values (greyed out text) 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. Agree cursor blocking is not great. LGTM. |
||
} | ||
val, err = prompter.RunPrompt(namespaceSelector) | ||
if err != nil { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -235,22 +235,15 @@ func installRadius(ctx context.Context, r *Runner) error { | |
func selectKubeContext(currentContext string, kubeContexts map[string]*api.Context, interactive bool, prompter prompt.Interface) (string, error) { | ||
values := []string{} | ||
if interactive { | ||
confirmDefaultContext, err := prompt.YesOrNoPrompter( | ||
fmt.Sprintf("Confirm default context: %s, %s", currentContext, "[Y/n]"), | ||
"Y", | ||
prompter, | ||
) | ||
if err != nil { | ||
return "", err | ||
} | ||
if strings.ToLower(confirmDefaultContext) == "y" { | ||
return currentContext, nil | ||
} | ||
defaultValue := fmt.Sprintf("%s (current)", currentContext) | ||
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. Simplify selection process by placing current at the top and appending 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. Love it. This is one of the ideas we discussed a few weeks ago, glad to see it come back. 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. This is nice! 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. The tests might fail though because it is one skipped terminal interaction. 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. Yep, getting this error:
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. should be good now |
||
values = append(values, defaultValue) | ||
for k := range kubeContexts { | ||
values = append(values, k) | ||
if k != currentContext { | ||
values = append(values, k) | ||
} | ||
} | ||
index, _, err := prompter.RunSelect(prompt.SelectionPrompter( | ||
"Select the context for radius installation", | ||
"Select the kubeconfig context to install Radius installation", | ||
values, | ||
)) | ||
if err != nil { | ||
|
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.
Because promptui already has a default experience, we don't need to manually build the prompt message with the default