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