(cmd *cobra.Command, args []string)
| 27 | } |
| 28 | |
| 29 | func 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 | } |
nothing calls this directly
no test coverage detected