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

Function webGetRun

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

Source from the content-addressed store, hash-verified

53}
54
55func webGetRun(cmd *cobra.Command, args []string) error {
56 fullORef, err := resolveBlockArg()
57 if err != nil {
58 return fmt.Errorf("resolving blockid: %w", err)
59 }
60 blockInfo, err := wshclient.BlockInfoCommand(RpcClient, fullORef.OID, nil)
61 if err != nil {
62 return fmt.Errorf("getting block info: %w", err)
63 }
64 if blockInfo.Block.Meta.GetString(waveobj.MetaKey_View, "") != "web" {
65 return fmt.Errorf("block %s is not a web block", fullORef.OID)
66 }
67 data := wshrpc.CommandWebSelectorData{
68 WorkspaceId: blockInfo.WorkspaceId,
69 BlockId: fullORef.OID,
70 TabId: blockInfo.TabId,
71 Selector: args[0],
72 Opts: &wshrpc.WebSelectorOpts{
73 Inner: webGetInner,
74 All: webGetAll,
75 },
76 }
77 output, err := wshclient.WebSelectorCommand(RpcClient, data, &wshrpc.RpcOpts{
78 Route: wshutil.ElectronRoute,
79 Timeout: 5000,
80 })
81 if err != nil {
82 return err
83 }
84 if webGetJson {
85 barr, err := json.MarshalIndent(output, "", " ")
86 if err != nil {
87 return fmt.Errorf("json encoding: %w", err)
88 }
89 WriteStdout("%s\n", string(barr))
90 } else {
91 for _, item := range output {
92 WriteStdout("%s\n", item)
93 }
94 }
95 return nil
96}
97
98func webOpenRun(cmd *cobra.Command, args []string) (rtnErr error) {
99 defer func() {

Callers

nothing calls this directly

Calls 5

BlockInfoCommandFunction · 0.92
WebSelectorCommandFunction · 0.92
resolveBlockArgFunction · 0.85
WriteStdoutFunction · 0.85
GetStringMethod · 0.80

Tested by

no test coverage detected