runInteractiveConfigInit shows an interactive TUI for config init.
(ctx context.Context, f *cmdutil.Factory, msg *initMsg)
| 29 | |
| 30 | // runInteractiveConfigInit shows an interactive TUI for config init. |
| 31 | func runInteractiveConfigInit(ctx context.Context, f *cmdutil.Factory, msg *initMsg) (*configInitResult, error) { |
| 32 | // Phase 1: Choose mode |
| 33 | var mode string |
| 34 | form1 := huh.NewForm( |
| 35 | huh.NewGroup( |
| 36 | huh.NewSelect[string](). |
| 37 | Title(msg.SelectAction). |
| 38 | Options( |
| 39 | huh.NewOption(msg.CreateNewApp, "create"), |
| 40 | huh.NewOption(msg.ConfigExistingApp, "existing"), |
| 41 | ). |
| 42 | Value(&mode), |
| 43 | ), |
| 44 | ).WithTheme(cmdutil.ThemeFeishu()) |
| 45 | |
| 46 | if err := form1.Run(); err != nil { |
| 47 | if err == huh.ErrUserAborted { |
| 48 | return nil, output.ErrBare(1) |
| 49 | } |
| 50 | return nil, err |
| 51 | } |
| 52 | |
| 53 | if mode == "existing" { |
| 54 | return runExistingAppForm(f, msg) |
| 55 | } |
| 56 | |
| 57 | return runCreateAppFlow(ctx, f, "", msg) |
| 58 | } |
| 59 | |
| 60 | // runExistingAppForm shows a huh form for manually entering App ID / App Secret / Brand. |
| 61 | func runExistingAppForm(f *cmdutil.Factory, msg *initMsg) (*configInitResult, error) { |
no test coverage detected