MCPcopy
hub / github.com/wavetermdev/waveterm / createBlockRun

Function createBlockRun

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

Source from the content-addressed store, hash-verified

29}
30
31func createBlockRun(cmd *cobra.Command, args []string) error {
32 viewName := args[0]
33 var metaSetStrs []string
34 if len(args) > 1 {
35 metaSetStrs = args[1:]
36 }
37 tabId := getTabIdFromEnv()
38 if tabId == "" {
39 return fmt.Errorf("no WAVETERM_TABID env var set")
40 }
41 meta, err := parseMetaSets(metaSetStrs)
42 if err != nil {
43 return err
44 }
45 meta["view"] = viewName
46 data := wshrpc.CommandCreateBlockData{
47 TabId: tabId,
48 BlockDef: &waveobj.BlockDef{
49 Meta: meta,
50 },
51 Magnified: createBlockMagnified,
52 Focused: true,
53 }
54 oref, err := wshclient.CreateBlockCommand(RpcClient, data, nil)
55 if err != nil {
56 return fmt.Errorf("create block failed: %v", err)
57 }
58 fmt.Printf("created block %s\n", oref.OID)
59 return nil
60}

Callers

nothing calls this directly

Calls 3

CreateBlockCommandFunction · 0.92
getTabIdFromEnvFunction · 0.85
parseMetaSetsFunction · 0.85

Tested by

no test coverage detected