MCPcopy Create free account
hub / github.com/cli/cli / commandLine

Method commandLine

script/ghmock/run.go:230–267  ·  view source on GitHub ↗

commandLine is the ghmock run command for these options, quoted for a POSIX shell.

()

Source from the content-addressed store, hash-verified

228// commandLine is the ghmock run command for these options, quoted for a
229// POSIX shell.
230func (o runOptions) commandLine() string {
231 parts := []string{"ghmock", "run"}
232 for _, b := range o.binaries {
233 parts = append(parts, "--gh", shellQuote(b))
234 }
235 if o.tty {
236 parts = append(parts, "--tty")
237 }
238 if o.terminal && len(o.keys) == 0 {
239 parts = append(parts, "--terminal")
240 }
241 for _, k := range o.keys {
242 parts = append(parts, "--keys", shellQuote(k))
243 }
244 if o.stdin != "" {
245 parts = append(parts, "--stdin", shellQuote(o.stdin))
246 }
247 if o.loggedOut {
248 parts = append(parts, "--logged-out")
249 }
250 if o.localhost {
251 parts = append(parts, "--localhost")
252 }
253 if o.configDir != "" {
254 parts = append(parts, "--config-dir", shellQuote(o.configDir))
255 }
256 if o.in != "" {
257 parts = append(parts, "--in", shellQuote(o.in))
258 }
259 if o.timeout != defaultTimeout {
260 parts = append(parts, "--timeout", o.timeout.String())
261 }
262 parts = append(parts, "--")
263 for _, a := range o.args {
264 parts = append(parts, shellQuote(a))
265 }
266 return strings.Join(parts, " ")
267}
268
269var shellSafe = regexp.MustCompile(`^[A-Za-z0-9_@%+=:,./-]+$`)
270

Callers 1

runAllFunction · 0.80

Calls 3

JoinMethod · 0.80
shellQuoteFunction · 0.70
StringMethod · 0.65

Tested by

no test coverage detected