cli

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 18, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ExitSuccess = 0
	ExitGhError = 1
	ExitNoRepo  = 2
	ExitNoPRs   = 3
	ExitUsage   = 64
)
View Source
const DefaultFormat = render.FormatText

DefaultFormat is the human-readable terminal output selected when neither --format nor GH_PRS_FORMAT is provided.

View Source
const USAGE = `` /* 1770-byte string literal not displayed */

Variables

This section is empty.

Functions

func Execute

func Execute(argv []string, env []string) int

Execute parses flags, runs the app, returns the exit code. Never panics; maps all errors to exit codes via MapError. Call site: main.go -> os.Exit(cli.Execute(os.Args[1:], os.Environ()))

func MapError

func MapError(err error, hasPRs bool) int

MapError maps any error to an exit code. Pass err=nil with hasPRs=false for the empty-results case (ExitNoPRs); hasPRs=true yields ExitSuccess.

func PrintRESTEquivalent

func PrintRESTEquivalent(owner, name string, stderr io.Writer)

PrintRESTEquivalent writes the 9-line "DEBUG REST equivalent" block to stderr when --debug is set. Signature mirrors the TS debug-output.ts.

func ShouldColor

func ShouldColor(env map[string]string, stdoutIsTTY bool) bool

ShouldColor decides whether ANSI color escapes are emitted. Rules (in order):

  1. NO_COLOR truthy => false
  2. FORCE_COLOR set => parse FORCE_COLOR as truthy-flag
  3. fall back to stdoutIsTTY

func ShouldOSC8

func ShouldOSC8(stdoutIsTTY bool) bool

ShouldOSC8 returns stdoutIsTTY. NO_COLOR does not gate OSC8.

Types

type Flags

type Flags struct {
	// Format is the canonical name of the chosen output format. Never empty:
	// composeFlags resolves missing input to DefaultFormat. Validity is
	// checked separately via render.Lookup in Execute.
	Format   string
	Debug    bool
	Help     bool
	NoCache  bool
	CacheTTL string
	Stats    bool
	// Authors holds the --author logins (repeatable flag). An empty slice
	// means the caller should apply the "@me" default. composeFlags never
	// injects "@me" here — that policy lives in runOnce where filter.Set
	// is constructed.
	Authors []string
}

func (Flags) Machine added in v0.3.0

func (f Flags) Machine() bool

Machine reports whether the selected format is for machine consumption (json/toon). Used to suppress TTY-oriented UX like the spinner and the "No open PRs" human message.

type Spinner

type Spinner struct {
	// contains filtered or unexported fields
}

Spinner writes a braille frame to stderr every spinnerInterval when started against a TTY. Stop is idempotent and always clears the current line.

func NewSpinner

func NewSpinner(enabled bool, stderrIsTTY bool, stderr io.Writer) *Spinner

NewSpinner constructs a spinner. enabled is the caller's intent (false for --json); stderrIsTTY short-circuits to a no-op when false.

func (*Spinner) Start

func (s *Spinner) Start()

func (*Spinner) Stop

func (s *Spinner) Stop()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL