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

Function tokenCmdRun

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

Source from the content-addressed store, hash-verified

22}
23
24func tokenCmdRun(cmd *cobra.Command, args []string) (rtnErr error) {
25 if len(args) != 2 {
26 OutputHelpMessage(cmd)
27 return fmt.Errorf("wsh token requires exactly 2 arguments, got %d", len(args))
28 }
29 tokenStr, shellType := args[0], args[1]
30 if tokenStr == "" || shellType == "" {
31 OutputHelpMessage(cmd)
32 return fmt.Errorf("wsh token requires non-empty arguments")
33 }
34 rtnData, err := setupRpcClientWithToken(tokenStr)
35 if err != nil {
36 return fmt.Errorf("error setting up rpc client: %w", err)
37 }
38 envScriptText, err := shellutil.EncodeEnvVarsForShell(shellType, rtnData.Env)
39 if err != nil {
40 return fmt.Errorf("error encoding env vars: %w", err)
41 }
42 WriteStdout("%s\n", envScriptText)
43 WriteStdout("%s\n", rtnData.InitScriptText)
44 return nil
45}

Callers

nothing calls this directly

Calls 4

EncodeEnvVarsForShellFunction · 0.92
OutputHelpMessageFunction · 0.85
setupRpcClientWithTokenFunction · 0.85
WriteStdoutFunction · 0.85

Tested by

no test coverage detected