Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 1 addition & 2 deletions cmd/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ func promptForAccountID(ctx context.Context) (string, error) {
}

return cmdio.RunPrompt(ctx, cmdio.PromptOptions{
Label: "Databricks account ID",
AllowEdit: true,
Label: "Databricks account ID",
})
}

Expand Down
6 changes: 2 additions & 4 deletions cmd/auth/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ func promptForProfile(ctx context.Context, defaultValue string) (string, error)
}

result, err := cmdio.RunPrompt(ctx, cmdio.PromptOptions{
Label: "Databricks profile name [" + defaultValue + "]",
AllowEdit: true,
Label: "Databricks profile name [" + defaultValue + "]",
})
if result == "" {
// Manually return the default value. We could use the prompt.Default
Expand Down Expand Up @@ -757,8 +756,7 @@ func promptForWorkspaceSelection(ctx context.Context, authArguments *auth.AuthAr
// Returns empty string if the user provides no input.
func promptForWorkspaceID(ctx context.Context) (string, error) {
result, err := cmdio.RunPrompt(ctx, cmdio.PromptOptions{
Label: "Enter workspace ID (empty to skip)",
AllowEdit: true,
Label: "Enter workspace ID (empty to skip)",
})
if err != nil {
return "", err
Expand Down
3 changes: 1 addition & 2 deletions cmd/configure/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ func configureInteractive(cmd *cobra.Command, flags *configureFlags, cfg *config
// Ask user to specify the host if not already set.
if cfg.Host == "" {
out, err := cmdio.RunPrompt(ctx, cmdio.PromptOptions{
Label: "Databricks workspace host (https://...)",
AllowEdit: true,
Label: "Databricks workspace host (https://...)",
Validate: func(input string) error {
normalized := normalizeHost(input)
return validateHost(normalized)
Expand Down
16 changes: 6 additions & 10 deletions libs/cmdio/prompt.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ type PromptOptions struct {
// (use '*' for password-style input).
Mask rune

// AllowEdit lets the user edit Default rather than overwriting it.
AllowEdit bool

// Validate, when set, is called on every keystroke; returning a non-nil
// error keeps the prompt open and shows the error to the user.
Validate func(input string) error
Expand All @@ -30,13 +27,12 @@ type PromptOptions struct {
func RunPrompt(ctx context.Context, opts PromptOptions) (string, error) {
c := fromContext(ctx)
p := promptui.Prompt{
Label: opts.Label,
Default: opts.Default,
Mask: opts.Mask,
AllowEdit: opts.AllowEdit,
Validate: opts.Validate,
Stdin: c.promptStdin(),
Stdout: nopWriteCloser{c.err},
Label: opts.Label,
Default: opts.Default,
Mask: opts.Mask,
Validate: opts.Validate,
Stdin: c.promptStdin(),
Stdout: nopWriteCloser{c.err},
}
return p.Run()
}