cli

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: MIT Imports: 44 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotAuthenticated = errors.New("not authenticated: run `rc login` or pass --api-key / set RC_API_KEY")

Functions

func ExitCodeFor

func ExitCodeFor(err error) int

func NewRootCmd

func NewRootCmd(version string) *cobra.Command

func Run

func Run(version string) int

Run is the entrypoint used by cmd/rc/main.go. Wraps cobra.Execute() so we can format final errors based on --json — emitting a structured envelope for agents and a friendly stderr message (with actionable hint) for humans.

Keeping this here (rather than in main.go) means the JSON error contract lives next to the JSON success contract in output.go.

func WithHint

func WithHint(err error, hint string) error

func WithRuntime

func WithRuntime(ctx context.Context, r *Runtime) context.Context

Types

type Choice

type Choice[T comparable] struct {
	Value T      // returned when this branch is chosen
	Label string // shown in the interactive picker
	Flag  string // the flag that selects this branch under --no-input (e.g. "--standalone")
}

Choice is one branch of a decision: what the human picks, and the flag a non-interactive caller passes to select it without the prompt.

type Globals

type Globals struct {
	JSON      bool
	NoInput   bool
	Quiet     bool
	Verbose   bool
	ShowAll   bool
	Profile   string
	APIKey    string
	ProjectID string
	Format    string // jq/gojq expression, applied to --json output
	NoColor   bool
	AssumeYes bool
	Version   string

	// CommandPath is the dotted path of the command being run (e.g.
	// "paywalls.generate"), set once in PersistentPreRunE. Used only for the
	// usage-analytics request header.
	CommandPath string
}

Globals bound to root persistent flags. Every subcommand reads these via context.

type PickerItem

type PickerItem struct {
	ID    string
	Label string // shown in the huh.Select; should be human-readable
}

PickerItem is a selectable entry in an interactive ID picker.

type Runtime

type Runtime struct {
	Globals *Globals
	Config  *config.Config
	Out     *output.Renderer
	Ctx     context.Context
	// contains filtered or unexported fields
}

func RuntimeFrom

func RuntimeFrom(ctx context.Context) *Runtime

func (*Runtime) API

func (r *Runtime) API() (*api.Client, error)

API returns a lazily-initialized API client built from the active config. If the active credential is a near-expiry OAuth token, a silent refresh is attempted first; when a flag or RC_API_KEY override is in charge the profile isn't touched (or re-saved).

func (*Runtime) CanPrompt

func (rt *Runtime) CanPrompt() bool

CanPrompt reports whether it's safe to show an interactive prompt: not in --json or --no-input mode, and attached to a TTY.

type SilentExitError

type SilentExitError struct{ Code int }

SilentExitError signals a specific exit code when the command has already written its own complete output. run.go skips the error envelope for this type so there is no duplicate output.

func (*SilentExitError) Error

func (e *SilentExitError) Error() string

Jump to

Keyboard shortcuts

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