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

Method Register

internal/run/stub.go:74–87  ·  view source on GitHub ↗

Register a stub for an external command. Pattern is a regular expression, output is the standard output from a command. Pass callbacks to inspect raw arguments that the command was invoked with.

(pattern string, exitStatus int, output string, callbacks ...CommandCallback)

Source from the content-addressed store, hash-verified

72// Register a stub for an external command. Pattern is a regular expression, output is the standard output
73// from a command. Pass callbacks to inspect raw arguments that the command was invoked with.
74func (cs *CommandStubber) Register(pattern string, exitStatus int, output string, callbacks ...CommandCallback) {
75 if len(pattern) < 1 {
76 panic("cannot use empty regexp pattern")
77 }
78 if strings.HasPrefix(pattern, "git") {
79 pattern = addGitAuthentication(pattern)
80 }
81 cs.stubs = append(cs.stubs, &commandStub{
82 pattern: regexp.MustCompile(pattern),
83 exitStatus: exitStatus,
84 stdout: output,
85 callbacks: callbacks,
86 })
87}
88
89func (cs *CommandStubber) find(args []string) *commandStub {
90 line := strings.Join(args, " ")

Callers 1

stubTreeAndBlobFunction · 0.45

Calls 1

addGitAuthenticationFunction · 0.85

Tested by 1

stubTreeAndBlobFunction · 0.36