cli

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: MIT Imports: 30 Imported by: 0

Documentation

Overview

Package cli assembles blip's command tree and maps failures onto exit codes.

Index

Constants

View Source
const PermissionRule = "Bash(blip:*)"

PermissionRule is what a project must allow for blip to run unprompted.

Variables

This section is empty.

Functions

func Execute

func Execute(args []string, stdout, stderr io.Writer) int

Execute runs the command tree and returns the process exit code.

func NewRootCommand

func NewRootCommand(rt *Runtime) *cobra.Command

NewRootCommand builds a command tree bound to rt. Nothing is package-global, so tests can run commands independently.

func Run

func Run(rt *Runtime, args []string) int

Run executes args against an already-built runtime and returns the exit code.

func Version

func Version() string

Version reports the version blip should call itself.

Types

type Globals

type Globals struct {
	ConfigPath     string
	Env            string
	Profile        string
	Refresh        bool
	Offline        bool
	Timeout        time.Duration
	Output         string
	IncludeHeaders bool
	Verbose        bool
	DryRun         bool
	Yes            bool
	Strict         bool
}

Globals are the flags that apply to every command.

type Runtime

type Runtime struct {
	Globals *Globals

	Stdout io.Writer
	Stderr io.Writer
	Stdin  *os.File

	// Input is where a request body or a confirmation is read from. It defaults
	// to Stdin; tests supply their own.
	Input io.Reader

	StdinIsTTY  bool
	StdoutIsTTY bool

	// Dir is where config discovery starts. Empty means the process working directory.
	Dir string
	// contains filtered or unexported fields
}

Runtime carries everything a command needs, resolving config, environment and credentials lazily so that --help and describe never reach for a vault.

func (*Runtime) API

func (rt *Runtime) API(ctx context.Context) (*build.API, error)

API returns the parsed command model for the resolved environment, merged with any hand-declared routes.

func (*Runtime) Authenticator

func (rt *Runtime) Authenticator(ctx context.Context) (auth.Authenticator, error)

Authenticator resolves credentials. It is called only when a request is about to be sent, so a vault is never consulted for --help or describe.

func (*Runtime) Client

func (rt *Runtime) Client() (*http.Client, error)

Client returns the HTTP client for the resolved environment. The tree is built before cobra parses flags, so the first caller cannot be allowed to fix the timeout for everyone.

func (*Runtime) Config

func (rt *Runtime) Config() (*config.Config, error)

Config returns the discovered .blip.toml.

func (*Runtime) Env

func (rt *Runtime) Env() (*config.Environment, error)

Env returns the resolved environment.

func (*Runtime) ProfileName

func (rt *Runtime) ProfileName() (string, error)

ProfileName is the credentials profile in force: --profile if given, otherwise whatever the environment names.

func (*Runtime) Redact

func (rt *Runtime) Redact(s string) string

Redact removes any secret blip has already resolved from a message on its way out. It never triggers resolution: printing an error must not reach a vault.

func (*Runtime) ReportSpecWarnings

func (rt *Runtime) ReportSpecWarnings(api *build.API, force bool)

ReportSpecWarnings puts spec problems on stderr when they are new, so a run against an unchanged spec stays quiet. It reports at most once per process.

func (*Runtime) Spec

func (rt *Runtime) Spec(ctx context.Context) (*spec.Spec, error)

Spec returns the OpenAPI document for the resolved environment.

func (*Runtime) Verbosef

func (rt *Runtime) Verbosef(format string, args ...any)

Verbosef writes a diagnostic only under --verbose.

func (*Runtime) Warnf

func (rt *Runtime) Warnf(format string, args ...any)

Warnf writes a diagnostic to stderr. Nothing blip warns about belongs on stdout.

Jump to

Keyboard shortcuts

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