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

Function runVersionCmd

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

Source from the content-addressed store, hash-verified

31}
32
33func runVersionCmd(cmd *cobra.Command, args []string) error {
34 if !versionVerbose && !versionJSON {
35 WriteStdout("wsh v%s\n", wavebase.WaveVersion)
36 return nil
37 }
38
39 err := preRunSetupRpcClient(cmd, args)
40 if err != nil {
41 return err
42 }
43
44 resp, err := wshclient.WaveInfoCommand(RpcClient, &wshrpc.RpcOpts{Timeout: 2000})
45 if err != nil {
46 return err
47 }
48
49 updateChannel, err := wshclient.GetUpdateChannelCommand(RpcClient, &wshrpc.RpcOpts{Timeout: 2000, Route: wshutil.ElectronRoute})
50 if err != nil {
51 return err
52 }
53
54 if versionJSON {
55 info := map[string]interface{}{
56 "version": resp.Version,
57 "clientid": resp.ClientId,
58 "buildtime": resp.BuildTime,
59 "configdir": resp.ConfigDir,
60 "datadir": resp.DataDir,
61 "updatechannel": updateChannel,
62 }
63 outBArr, err := json.MarshalIndent(info, "", " ")
64 if err != nil {
65 return fmt.Errorf("formatting version info: %v", err)
66 }
67 WriteStdout("%s\n", string(outBArr))
68 return nil
69 }
70
71 // Default verbose text output
72 fmt.Printf("v%s (%s)\n", resp.Version, resp.BuildTime)
73 fmt.Printf("clientid: %s\n", resp.ClientId)
74 fmt.Printf("configdir: %s\n", resp.ConfigDir)
75 fmt.Printf("datadir: %s\n", resp.DataDir)
76 fmt.Printf("update-channel: %s\n", updateChannel)
77 return nil
78}

Callers

nothing calls this directly

Calls 4

WaveInfoCommandFunction · 0.92
GetUpdateChannelCommandFunction · 0.92
WriteStdoutFunction · 0.85
preRunSetupRpcClientFunction · 0.85

Tested by

no test coverage detected