(cmd *cobra.Command, args []string)
| 31 | } |
| 32 | |
| 33 | func termRun(cmd *cobra.Command, args []string) (rtnErr error) { |
| 34 | defer func() { |
| 35 | sendActivity("term", rtnErr == nil) |
| 36 | }() |
| 37 | |
| 38 | var cwd string |
| 39 | if len(args) > 0 { |
| 40 | cwd = args[0] |
| 41 | cwdExpanded, err := wavebase.ExpandHomeDir(cwd) |
| 42 | if err != nil { |
| 43 | return err |
| 44 | } |
| 45 | cwd = cwdExpanded |
| 46 | } else { |
| 47 | var err error |
| 48 | cwd, err = os.Getwd() |
| 49 | if err != nil { |
| 50 | return fmt.Errorf("getting current directory: %w", err) |
| 51 | } |
| 52 | } |
| 53 | var err error |
| 54 | cwd, err = filepath.Abs(cwd) |
| 55 | if err != nil { |
| 56 | return fmt.Errorf("getting absolute path: %w", err) |
| 57 | } |
| 58 | |
| 59 | tabId := getTabIdFromEnv() |
| 60 | if tabId == "" { |
| 61 | return fmt.Errorf("no WAVETERM_TABID env var set") |
| 62 | } |
| 63 | |
| 64 | createMeta := map[string]any{ |
| 65 | waveobj.MetaKey_View: "term", |
| 66 | waveobj.MetaKey_CmdCwd: cwd, |
| 67 | waveobj.MetaKey_Controller: "shell", |
| 68 | } |
| 69 | if RpcContext.Conn != "" { |
| 70 | createMeta[waveobj.MetaKey_Connection] = RpcContext.Conn |
| 71 | } |
| 72 | createBlockData := wshrpc.CommandCreateBlockData{ |
| 73 | TabId: tabId, |
| 74 | BlockDef: &waveobj.BlockDef{ |
| 75 | Meta: createMeta, |
| 76 | }, |
| 77 | Magnified: termMagnified, |
| 78 | Focused: true, |
| 79 | } |
| 80 | oref, err := wshclient.CreateBlockCommand(RpcClient, createBlockData, nil) |
| 81 | if err != nil { |
| 82 | return fmt.Errorf("creating new terminal block: %w", err) |
| 83 | } |
| 84 | WriteStdout("terminal block created: %s\n", oref) |
| 85 | return nil |
| 86 | } |
nothing calls this directly
no test coverage detected