MCPcopy Index your code
hub / github.com/wavetermdev/waveterm / webOpenRun

Function webOpenRun

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

Source from the content-addressed store, hash-verified

96}
97
98func webOpenRun(cmd *cobra.Command, args []string) (rtnErr error) {
99 defer func() {
100 sendActivity("web", rtnErr == nil)
101 }()
102
103 var replaceBlockORef *waveobj.ORef
104 if webOpenReplaceBlock != "" {
105 var err error
106 replaceBlockORef, err = resolveSimpleId(webOpenReplaceBlock)
107 if err != nil {
108 return fmt.Errorf("resolving -r blockid: %w", err)
109 }
110 }
111 if replaceBlockORef != nil && webOpenMagnified {
112 return fmt.Errorf("cannot use --replace and --magnified together")
113 }
114
115 tabId := getTabIdFromEnv()
116 if tabId == "" {
117 return fmt.Errorf("no WAVETERM_TABID env var set")
118 }
119
120 wshCmd := wshrpc.CommandCreateBlockData{
121 TabId: tabId,
122 BlockDef: &waveobj.BlockDef{
123 Meta: map[string]any{
124 waveobj.MetaKey_View: "web",
125 waveobj.MetaKey_Url: args[0],
126 },
127 },
128 Magnified: webOpenMagnified,
129 Focused: true,
130 }
131 if replaceBlockORef != nil {
132 wshCmd.TargetBlockId = replaceBlockORef.OID
133 wshCmd.TargetAction = wshrpc.CreateBlockAction_Replace
134 }
135 oref, err := wshclient.CreateBlockCommand(RpcClient, wshCmd, nil)
136 if err != nil {
137 return fmt.Errorf("creating block: %w", err)
138 }
139 WriteStdout("created block %s\n", oref)
140 return nil
141}

Callers

nothing calls this directly

Calls 5

CreateBlockCommandFunction · 0.92
sendActivityFunction · 0.85
getTabIdFromEnvFunction · 0.85
WriteStdoutFunction · 0.85
resolveSimpleIdFunction · 0.70

Tested by

no test coverage detected