mirror of https://github.com/databricks/cli.git
Print y/n options when displaying prompts using cmdio.Ask (#650)
## Changes Adds `[y/n]` in `cmdio.Ask` to make the options obvious in all question prompts ## Tests Test manually. Works.
This commit is contained in:
parent
54a1bcd10a
commit
6430d23453
|
@ -27,7 +27,7 @@ func (m *delete) Apply(ctx context.Context, b *bundle.Bundle) error {
|
||||||
|
|
||||||
red := color.New(color.FgRed).SprintFunc()
|
red := color.New(color.FgRed).SprintFunc()
|
||||||
if !b.AutoApprove {
|
if !b.AutoApprove {
|
||||||
proceed, err := cmdio.Ask(ctx, fmt.Sprintf("\n%s and all files in it will be %s Proceed?: ", b.Config.Workspace.RootPath, red("deleted permanently!")))
|
proceed, err := cmdio.Ask(ctx, fmt.Sprintf("\n%s and all files in it will be %s Proceed?", b.Config.Workspace.RootPath, red("deleted permanently!")))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,7 @@ func (w *destroy) Apply(ctx context.Context, b *bundle.Bundle) error {
|
||||||
// Ask for confirmation, if needed
|
// Ask for confirmation, if needed
|
||||||
if !b.Plan.ConfirmApply {
|
if !b.Plan.ConfirmApply {
|
||||||
red := color.New(color.FgRed).SprintFunc()
|
red := color.New(color.FgRed).SprintFunc()
|
||||||
b.Plan.ConfirmApply, err = cmdio.Ask(ctx, fmt.Sprintf("\nThis will permanently %s resources! Proceed? [y/n]: ", red("destroy")))
|
b.Plan.ConfirmApply, err = cmdio.Ask(ctx, fmt.Sprintf("\nThis will permanently %s resources! Proceed?", red("destroy")))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,6 +87,8 @@ func (l *Logger) Ask(question string) (bool, error) {
|
||||||
return false, fmt.Errorf("question prompts are not supported in json mode")
|
return false, fmt.Errorf("question prompts are not supported in json mode")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add acceptable answers to the question prompt.
|
||||||
|
question += ` [y/n]:`
|
||||||
l.Writer.Write([]byte(question))
|
l.Writer.Write([]byte(question))
|
||||||
ans, err := l.Reader.ReadString('\n')
|
ans, err := l.Reader.ReadString('\n')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue