cli

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

Package cli defines the command surface. It stays deliberately thin: parse flags, resolve config, call a package, hand the result to output. Business logic that appears here belongs somewhere else.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Execute

func Execute(ctx context.Context, env *Env, args []string) error

Execute builds the command tree, runs it, and returns the error the exit-code map will classify.

Types

type Env

type Env struct {
	Streams *output.Streams
	Stdin   io.Reader
	// Getenv defaults to os.Getenv.
	Getenv func(string) string
	// Now defaults to time.Now. Every date range derives from it.
	Now func() time.Time
	// Interactive reports whether a human can answer a prompt.
	Interactive func() bool
	// OpenBrowser defaults to launching the system browser.
	OpenBrowser func(url string) error
	// APIEndpoint overrides the Search Console base URL. Tests only.
	APIEndpoint string
	// Retry is passed through to the API client.
	Retry api.RetryPolicy
	// InspectRate paces batch inspection, in requests per second. Zero selects
	// the default; tests raise it so pacing does not slow the suite down.
	InspectRate int

	Version string
	Commit  string
	// contains filtered or unexported fields
}

Env is everything a command needs that would otherwise be global state. Injecting it is what lets the whole command surface be tested in-process, with no environment variables set and no browser opened.

func (*Env) ResultFormat

func (e *Env) ResultFormat() output.Format

ResultFormat is the format the caller asked for, defaulting to json when the run failed before --format could be parsed.

Jump to

Keyboard shortcuts

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