MCPcopy Create free account
hub / github.com/wavetermdev/waveterm / launchRun

Function launchRun

cmd/wsh/cmd/wshcmd-launch.go:29–72  ·  view source on GitHub ↗
(cmd *cobra.Command, args []string)

Source from the content-addressed store, hash-verified

27}
28
29func launchRun(cmd *cobra.Command, args []string) (rtnErr error) {
30 defer func() {
31 sendActivity("launch", rtnErr == nil)
32 }()
33
34 widgetId := args[0]
35
36 // Get the full configuration
37 config, err := wshclient.GetFullConfigCommand(RpcClient, &wshrpc.RpcOpts{Timeout: 2000})
38 if err != nil {
39 return fmt.Errorf("getting configuration: %w", err)
40 }
41
42 // Look for widget in both widgets and defaultwidgets
43 widget, ok := config.Widgets[widgetId]
44 if !ok {
45 widget, ok = config.DefaultWidgets[widgetId]
46 if !ok {
47 return fmt.Errorf("widget %q not found in configuration", widgetId)
48 }
49 }
50
51 tabId := getTabIdFromEnv()
52 if tabId == "" {
53 return fmt.Errorf("no WAVETERM_TABID env var set")
54 }
55
56 // Create block data from widget config
57 createBlockData := wshrpc.CommandCreateBlockData{
58 TabId: tabId,
59 BlockDef: &widget.BlockDef,
60 Magnified: magnifyBlock || widget.Magnified,
61 Focused: true,
62 }
63
64 // Create the block
65 oref, err := wshclient.CreateBlockCommand(RpcClient, createBlockData, nil)
66 if err != nil {
67 return fmt.Errorf("creating widget block: %w", err)
68 }
69
70 WriteStdout("launched widget %q: %s\n", widgetId, oref)
71 return nil
72}

Callers

nothing calls this directly

Calls 5

GetFullConfigCommandFunction · 0.92
CreateBlockCommandFunction · 0.92
sendActivityFunction · 0.85
getTabIdFromEnvFunction · 0.85
WriteStdoutFunction · 0.85

Tested by

no test coverage detected