-
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
Conversation
@@ -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)) |
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
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Simplify selection process by placing current at the top and appending (current)
, and just using a selection prompt
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.
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 comment
The 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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, getting this error:
=== RUN Test_Validate/Valid_Init_Command
shared.go:73: assertion failed: expected error to contain "cluster unreachable", got "KubeContext not specified": Error should be: kubernetes cluster unreachable, got: KubeContext not specified
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.
should be good now
/cc @bjoginapally |
Double prompts are caused by manifoldco/promptui#129, which has an open PR. Just pinged the maintainers to review. |
@@ -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 comment
The 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 comment
The 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 comment
The 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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Agree cursor blocking is not great. LGTM.
* Fix double semicolon and cursor location * Update kubeconfig selection logic * Auto formatting * Correct integration tests Co-authored-by: Bharath Joginapally <[email protected]>
Description
Issue reference
Partially addresses
Partially fixes: radius-project/core-team#946
Checklist
Please make sure you've completed the relevant tasks for this PR, out of the following list: