Documentation
¶
Overview ¶
Package cli assembles blip's command tree and maps failures onto exit codes.
Index ¶
- Constants
- func Execute(args []string, stdout, stderr io.Writer) int
- func NewRootCommand(rt *Runtime) *cobra.Command
- func Run(rt *Runtime, args []string) int
- func Version() string
- type Globals
- type Runtime
- func (rt *Runtime) API(ctx context.Context) (*build.API, error)
- func (rt *Runtime) Authenticator(ctx context.Context) (auth.Authenticator, error)
- func (rt *Runtime) Client() (*http.Client, error)
- func (rt *Runtime) Config() (*config.Config, error)
- func (rt *Runtime) Env() (*config.Environment, error)
- func (rt *Runtime) ProfileName() (string, error)
- func (rt *Runtime) Redact(s string) string
- func (rt *Runtime) ReportSpecWarnings(api *build.API, force bool)
- func (rt *Runtime) Spec(ctx context.Context) (*spec.Spec, error)
- func (rt *Runtime) Verbosef(format string, args ...any)
- func (rt *Runtime) Warnf(format string, args ...any)
Constants ¶
const PermissionRule = "Bash(blip:*)"
PermissionRule is what a project must allow for blip to run unprompted.
Variables ¶
This section is empty.
Functions ¶
func NewRootCommand ¶
NewRootCommand builds a command tree bound to rt. Nothing is package-global, so tests can run commands independently.
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 ¶
API returns the parsed command model for the resolved environment, merged with any hand-declared routes.
func (*Runtime) Authenticator ¶
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 ¶
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) Env ¶
func (rt *Runtime) Env() (*config.Environment, error)
Env returns the resolved environment.
func (*Runtime) ProfileName ¶
ProfileName is the credentials profile in force: --profile if given, otherwise whatever the environment names.
func (*Runtime) Redact ¶
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 ¶
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.