MCPcopy
hub / github.com/larksuite/cli / runInteractiveConfigInit

Function runInteractiveConfigInit

cmd/config/init_interactive.go:31–58  ·  view source on GitHub ↗

runInteractiveConfigInit shows an interactive TUI for config init.

(ctx context.Context, f *cmdutil.Factory, msg *initMsg)

Source from the content-addressed store, hash-verified

29
30// runInteractiveConfigInit shows an interactive TUI for config init.
31func 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.
61func runExistingAppForm(f *cmdutil.Factory, msg *initMsg) (*configInitResult, error) {

Callers 1

configInitRunFunction · 0.85

Calls 5

ThemeFeishuFunction · 0.92
ErrBareFunction · 0.92
runExistingAppFormFunction · 0.85
runCreateAppFlowFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected