Skip to content

Commit 1b1ad15

Browse files
authored
cmdio: drop unused PromptOptions.AllowEdit (#5177)
## Summary `AllowEdit` only affects how `promptui` renders a non-empty `Default`: with `AllowEdit:true` the default pre-fills the buffer; with `AllowEdit:false` it appears as a placeholder that's wiped on first keystroke. No caller in the repo sets `Default`, so the field has been a no-op everywhere it was passed. Drop it rather than carry an option that does nothing. ## Test plan - [x] `go build ./...` - [x] `go vet ./cmd/configure/... ./cmd/auth/... ./libs/cmdio/...` - [x] `go test ./libs/cmdio/... ./cmd/configure/... ./cmd/auth/...` This pull request and its description were written by Isaac.
1 parent 74fb879 commit 1b1ad15

4 files changed

Lines changed: 10 additions & 18 deletions

File tree

cmd/auth/auth.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ func promptForAccountID(ctx context.Context) (string, error) {
5656
}
5757

5858
return cmdio.RunPrompt(ctx, cmdio.PromptOptions{
59-
Label: "Databricks account ID",
60-
AllowEdit: true,
59+
Label: "Databricks account ID",
6160
})
6261
}
6362

cmd/auth/login.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ func promptForProfile(ctx context.Context, defaultValue string) (string, error)
3333
}
3434

3535
result, err := cmdio.RunPrompt(ctx, cmdio.PromptOptions{
36-
Label: "Databricks profile name [" + defaultValue + "]",
37-
AllowEdit: true,
36+
Label: "Databricks profile name [" + defaultValue + "]",
3837
})
3938
if result == "" {
4039
// Manually return the default value. We could use the prompt.Default
@@ -757,8 +756,7 @@ func promptForWorkspaceSelection(ctx context.Context, authArguments *auth.AuthAr
757756
// Returns empty string if the user provides no input.
758757
func promptForWorkspaceID(ctx context.Context) (string, error) {
759758
result, err := cmdio.RunPrompt(ctx, cmdio.PromptOptions{
760-
Label: "Enter workspace ID (empty to skip)",
761-
AllowEdit: true,
759+
Label: "Enter workspace ID (empty to skip)",
762760
})
763761
if err != nil {
764762
return "", err

cmd/configure/configure.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ func configureInteractive(cmd *cobra.Command, flags *configureFlags, cfg *config
2828
// Ask user to specify the host if not already set.
2929
if cfg.Host == "" {
3030
out, err := cmdio.RunPrompt(ctx, cmdio.PromptOptions{
31-
Label: "Databricks workspace host (https://...)",
32-
AllowEdit: true,
31+
Label: "Databricks workspace host (https://...)",
3332
Validate: func(input string) error {
3433
normalized := normalizeHost(input)
3534
return validateHost(normalized)

libs/cmdio/prompt.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ type PromptOptions struct {
1818
// (use '*' for password-style input).
1919
Mask rune
2020

21-
// AllowEdit lets the user edit Default rather than overwriting it.
22-
AllowEdit bool
23-
2421
// Validate, when set, is called on every keystroke; returning a non-nil
2522
// error keeps the prompt open and shows the error to the user.
2623
Validate func(input string) error
@@ -30,13 +27,12 @@ type PromptOptions struct {
3027
func RunPrompt(ctx context.Context, opts PromptOptions) (string, error) {
3128
c := fromContext(ctx)
3229
p := promptui.Prompt{
33-
Label: opts.Label,
34-
Default: opts.Default,
35-
Mask: opts.Mask,
36-
AllowEdit: opts.AllowEdit,
37-
Validate: opts.Validate,
38-
Stdin: c.promptStdin(),
39-
Stdout: nopWriteCloser{c.err},
30+
Label: opts.Label,
31+
Default: opts.Default,
32+
Mask: opts.Mask,
33+
Validate: opts.Validate,
34+
Stdin: c.promptStdin(),
35+
Stdout: nopWriteCloser{c.err},
4036
}
4137
return p.Run()
4238
}

0 commit comments

Comments
 (0)