diff --git a/cmd/namespace.go b/cmd/namespace.go index b0df0832..7eca6f0c 100644 --- a/cmd/namespace.go +++ b/cmd/namespace.go @@ -8,8 +8,8 @@ import ( "github.com/MakeNowJust/heredoc" "github.com/dustin/go-humanize" "github.com/odpf/salt/printer" + "github.com/odpf/salt/prompt" "github.com/odpf/salt/term" - "github.com/odpf/stencil/pkg/prompt" stencilv1beta1 "github.com/odpf/stencil/proto/odpf/stencil/v1beta1" "github.com/spf13/cobra" "google.golang.org/grpc/codes" diff --git a/pkg/prompt/prompt.go b/pkg/prompt/prompt.go deleted file mode 100644 index ae638758..00000000 --- a/pkg/prompt/prompt.go +++ /dev/null @@ -1,73 +0,0 @@ -package prompt - -import ( - "fmt" - - "github.com/AlecAivazis/survey/v2" -) - -type Prompter interface { - Select(string, string, []string) (int, error) - MultiSelect(string, string, []string) (int, error) - Input(string, string) (string, error) - Confirm(string, bool) (bool, error) -} - -func New() Prompter { - return &surveyPrompter{} -} - -type surveyPrompter struct { -} - -func (p *surveyPrompter) ask(q survey.Prompt, response interface{}) error { - err := survey.AskOne(q, response) - if err == nil { - return nil - } - return fmt.Errorf("could not prompt: %w", err) -} - -func (p *surveyPrompter) Select(message, defaultValue string, options []string) (result int, err error) { - q := &survey.Select{ - Message: message, - Default: defaultValue, - Options: options, - PageSize: 20, - } - - err = p.ask(q, &result) - - return -} - -func (p *surveyPrompter) MultiSelect(message, defaultValue string, options []string) (result int, err error) { - q := &survey.MultiSelect{ - Message: message, - Default: defaultValue, - Options: options, - PageSize: 20, - } - - err = p.ask(q, &result) - - return -} - -func (p *surveyPrompter) Input(prompt, defaultValue string) (result string, err error) { - err = p.ask(&survey.Input{ - Message: prompt, - Default: defaultValue, - }, &result) - - return -} - -func (p *surveyPrompter) Confirm(prompt string, defaultValue bool) (result bool, err error) { - err = p.ask(&survey.Confirm{ - Message: prompt, - Default: defaultValue, - }, &result) - - return -}