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

Function wslRun

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

Source from the content-addressed store, hash-verified

29}
30
31func wslRun(cmd *cobra.Command, args []string) (rtnErr error) {
32 defer func() {
33 sendActivity("wsl", rtnErr == nil)
34 }()
35
36 var err error
37 if distroName == "" {
38 // get default distro from the host
39 distroName, err = wshclient.WslDefaultDistroCommand(RpcClient, nil)
40 if err != nil {
41 return err
42 }
43 }
44 if !strings.HasPrefix(distroName, "wsl://") {
45 distroName = "wsl://" + distroName
46 }
47 blockId := RpcContext.BlockId
48 if blockId == "" {
49 return fmt.Errorf("cannot determine blockid (not in JWT)")
50 }
51 data := wshrpc.CommandSetMetaData{
52 ORef: waveobj.MakeORef(waveobj.OType_Block, blockId),
53 Meta: map[string]any{
54 waveobj.MetaKey_Connection: distroName,
55 },
56 }
57 err = wshclient.SetMetaCommand(RpcClient, data, nil)
58 if err != nil {
59 return fmt.Errorf("setting connection in block: %w", err)
60 }
61 WriteStderr("switched connection to %q\n", distroName)
62 return nil
63}

Callers

nothing calls this directly

Calls 5

WslDefaultDistroCommandFunction · 0.92
MakeORefFunction · 0.92
SetMetaCommandFunction · 0.92
sendActivityFunction · 0.85
WriteStderrFunction · 0.85

Tested by

no test coverage detected