Documentation
¶
Overview ¶
Package ghissue wraps the gh CLI to create GitHub issues.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps the gh CLI. The zero value is not usable; use NewClient.
func NewClient ¶
func NewClient() *Client
NewClient returns a Client backed by the real os/exec runner.
func NewClientWithRunner ¶
func NewClientWithRunner(r CommandRunner, lookPath LookPathFunc) *Client
NewClientWithRunner returns a Client using the given runner and lookup function. Both must be non-nil. Used by tests.
func (*Client) Open ¶
Open invokes `gh issue create` to create a GitHub issue in repo.
repo must be in "owner/name" form. On success returns the URL of the new issue (the first http(s) line gh prints to stdout). Errors are returned as *CodedError so callers can branch on output.ErrorCode without string matching.
Error mapping:
- gh not on PATH → ErrGhNotInstalled
- exit code 4 → ErrGhNotAuthenticated (gh's auth-failure code)
- any other non-zero → ErrIssueCreateFailed
type CodedError ¶
CodedError carries an output.ErrorCode alongside a human message so the CLI layer can map errors back into the JSON envelope without re-parsing.
func (*CodedError) Error ¶
func (e *CodedError) Error() string
type CommandRunner ¶
type CommandRunner interface {
Run(ctx context.Context, name string, args []string, stdin []byte) (stdout, stderr []byte, exitCode int, err error)
}
CommandRunner abstracts process execution so tests can inject fakes instead of spawning a real `gh` binary. stdin is piped to the child process; the returned stdout/stderr are the full captured streams. exitCode is the process exit status (0 on success); err is non-nil only for spawn/setup failures (a non-zero exit is reported via exitCode, not err).
type Draft ¶
type Draft struct {
Title string `json:"title"`
Body string `json:"body"`
Labels []string `json:"labels,omitempty"`
Assignees []string `json:"assignees,omitempty"`
}
Draft is the in-memory representation of a GitHub issue draft to be created via `gh issue create`. It is normally loaded from a JSON file written by a caller (a skill, an automation, or a human via editor).
Labels and Assignees are optional; when empty they are omitted from the `gh` invocation.
type LookPathFunc ¶
LookPathFunc resolves an executable on PATH. Override in tests.