Skip to content

Commit

Permalink
Style prompts
Browse files Browse the repository at this point in the history
  • Loading branch information
Widcket committed Jan 26, 2021
1 parent 307cec6 commit 57e4924
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion internal/cli/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ func deleteRulesCmd(cli *cli) *cobra.Command {
},
}

cmd.Flags().StringVar(&flags.id, "id", "", "ID of the rule to delete (required)")
cmd.Flags().StringVarP(&flags.id, "id", "i", "", "ID of the rule to delete (required)")
cmd.Flags().BoolVarP(&flags.force, "force", "f", false, "Do not ask for confirmation.")
mustRequireFlags(cmd, "id")

Expand Down
12 changes: 10 additions & 2 deletions internal/prompt/prompt.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,16 @@ import (

var stdErrWriter = survey.WithStdio(os.Stdin, os.Stderr, os.Stderr)

var icons = survey.WithIcons(func(icons *survey.IconSet) {
icons.Question.Text = ""
})

func Ask(inputs []*survey.Question, response interface{}) error {
return survey.Ask(inputs, response, stdErrWriter)
return survey.Ask(inputs, response, stdErrWriter, icons)
}

func AskOne(prompt survey.Prompt, response interface{}) error {
return survey.AskOne(prompt, response, stdErrWriter, icons)
}

func TextInput(name string, message string, help string, value string, required bool) *survey.Question {
Expand Down Expand Up @@ -46,7 +54,7 @@ func Confirm(message string) bool {
Message: message,
}

if err := survey.AskOne(prompt, &result, stdErrWriter); err != nil {
if err := AskOne(prompt, &result); err != nil {
return false
}

Expand Down

0 comments on commit 57e4924

Please sign in to comment.