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

Function runRun

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

Source from the content-addressed store, hash-verified

39}
40
41func runRun(cmd *cobra.Command, args []string) (rtnErr error) {
42 defer func() {
43 sendActivity("run", rtnErr == nil)
44 }()
45
46 flags := cmd.Flags()
47 magnified, _ := flags.GetBool("magnified")
48 commandArg, _ := flags.GetString("command")
49 exit, _ := flags.GetBool("exit")
50 forceExit, _ := flags.GetBool("forceexit")
51 paused, _ := flags.GetBool("paused")
52 cwd, _ := flags.GetString("cwd")
53 delayMs, _ := flags.GetInt("delay")
54 appendOutput, _ := flags.GetBool("append")
55 var cmdArgs []string
56 var useShell bool
57 var shellCmd string
58
59 for i, arg := range os.Args {
60 if arg == "--" {
61 if i+1 >= len(os.Args) {
62 OutputHelpMessage(cmd)
63 return fmt.Errorf("no command provided after --")
64 }
65 shellCmd = os.Args[i+1]
66 cmdArgs = os.Args[i+2:]
67 break
68 }
69 }
70 if shellCmd != "" && commandArg != "" {
71 OutputHelpMessage(cmd)
72 return fmt.Errorf("cannot specify both -c and command arguments")
73 }
74 if shellCmd == "" && commandArg == "" {
75 OutputHelpMessage(cmd)
76 return fmt.Errorf("command must be specified after -- or with -c")
77 }
78 if commandArg != "" {
79 shellCmd = commandArg
80 useShell = true
81 }
82
83 // Get current working directory
84 if cwd == "" {
85 var err error
86 cwd, err = os.Getwd()
87 if err != nil {
88 return fmt.Errorf("getting current directory: %w", err)
89 }
90 }
91 cwd, err := filepath.Abs(cwd)
92 if err != nil {
93 return fmt.Errorf("getting absolute path: %w", err)
94 }
95
96 // Get current environment and convert to map
97 envMap := make(map[string]string)
98 for _, envStr := range os.Environ() {

Callers

nothing calls this directly

Calls 9

MapToEnvFunction · 0.92
CreateBlockCommandFunction · 0.92
sendActivityFunction · 0.85
OutputHelpMessageFunction · 0.85
getTabIdFromEnvFunction · 0.85
WriteStdoutFunction · 0.85
GetBoolMethod · 0.80
GetStringMethod · 0.80
GetIntMethod · 0.80

Tested by

no test coverage detected