(f *cmdutil.Factory, runF func(*prompterOptions) error)
| 20 | } |
| 21 | |
| 22 | func NewCmdPrompter(f *cmdutil.Factory, runF func(*prompterOptions) error) *cobra.Command { |
| 23 | opts := &prompterOptions{ |
| 24 | IO: f.IOStreams, |
| 25 | Config: f.Config, |
| 26 | } |
| 27 | |
| 28 | const ( |
| 29 | selectPrompt = "select" |
| 30 | multiSelectPrompt = "multi-select" |
| 31 | multiSelectWithSearchPrompt = "multi-select-with-search" |
| 32 | inputPrompt = "input" |
| 33 | passwordPrompt = "password" |
| 34 | confirmPrompt = "confirm" |
| 35 | authTokenPrompt = "auth-token" |
| 36 | confirmDeletionPrompt = "confirm-deletion" |
| 37 | inputHostnamePrompt = "input-hostname" |
| 38 | markdownEditorPrompt = "markdown-editor" |
| 39 | ) |
| 40 | |
| 41 | prompterTypeFuncMap := map[string]func(prompter.Prompter, *iostreams.IOStreams) error{ |
| 42 | selectPrompt: runSelect, |
| 43 | multiSelectPrompt: runMultiSelect, |
| 44 | multiSelectWithSearchPrompt: runMultiSelectWithSearch, |
| 45 | inputPrompt: runInput, |
| 46 | passwordPrompt: runPassword, |
| 47 | confirmPrompt: runConfirm, |
| 48 | authTokenPrompt: runAuthToken, |
| 49 | confirmDeletionPrompt: runConfirmDeletion, |
| 50 | inputHostnamePrompt: runInputHostname, |
| 51 | markdownEditorPrompt: runMarkdownEditor, |
| 52 | } |
| 53 | |
| 54 | allPromptsOrder := []string{ |
| 55 | selectPrompt, |
| 56 | multiSelectPrompt, |
| 57 | multiSelectWithSearchPrompt, |
| 58 | inputPrompt, |
| 59 | passwordPrompt, |
| 60 | confirmPrompt, |
| 61 | authTokenPrompt, |
| 62 | confirmDeletionPrompt, |
| 63 | inputHostnamePrompt, |
| 64 | markdownEditorPrompt, |
| 65 | } |
| 66 | |
| 67 | cmd := &cobra.Command{ |
| 68 | Use: "prompter [prompt type]", |
| 69 | Short: "Execute a test program to preview the prompter", |
| 70 | Long: heredoc.Doc(` |
| 71 | Execute a test program to preview the prompter. |
| 72 | Without an argument, all prompts will be run. |
| 73 | |
| 74 | Available prompt types: |
| 75 | - select |
| 76 | - multi-select |
| 77 | - multi-select-with-search |
| 78 | - input |
| 79 | - password |
nothing calls this directly
no test coverage detected