Help us shape the future of Go! Take the 2026 Go Developer Survey

cmd

package
v0.32.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: MIT Imports: 52 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AppVersion = "dev"
	BuildTime  = "unknown"
	GitCommit  = "unknown"
	AccountID  string
	APIToken   string
	DryRun     bool
	JSONOutput bool
	Verbose    bool
	// EnvProfile holds the --env flag value: the named environment profile
	// selected for this invocation (does not change the current profile).
	EnvProfile string
	// ActiveProfile is the resolved --env profile for this invocation, or
	// nil when no --env was given. Other commands read it via the
	// accessor semantics of this package-level variable (FEAT-026).
	ActiveProfile *config.Profile
)

Build information

Functions

func APIToken2ZoneID added in v0.31.0

func APIToken2ZoneID() string

APIToken2ZoneID keeps the zone ID dependency explicit for the seam var above without new global state.

func Execute

func Execute() error

Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

func RegisterCompletionFlags

func RegisterCompletionFlags()

RegisterCompletionFlags sets up dynamic shell completions for commands that accept bucket names as positional arguments.

func SetBuildInfo

func SetBuildInfo(version, buildTime, gitCommit string)

SetBuildInfo sets the build information

Types

type AnalyticsResult

type AnalyticsResult struct {
	Buckets []BucketStat `json:"buckets"`
	Total   BucketStat   `json:"total"`
	Period  string       `json:"period"`
}

type AuthCredentials

type AuthCredentials struct {
	APIToken  string
	AccountID string
	Email     string
	AccessKey string
	SecretKey string
	Method    string
	Scope     string
	ExpiresAt time.Time
}

type BatchOperation

type BatchOperation struct {
	Action         string `json:"action"`
	LocalPath      string `json:"local_path,omitempty"`
	ObjectKey      string `json:"object_key,omitempty"`
	DestinationKey string `json:"destination_key,omitempty"`
}

type BatchSpec

type BatchSpec struct {
	Operations []BatchOperation `json:"operations"`
}

type BucketSpec

type BucketSpec struct {
	Buckets []BucketSpecItem `json:"buckets" yaml:"buckets"`
}

type BucketSpecItem

type BucketSpecItem struct {
	Name     string            `json:"name" yaml:"name"`
	Location string            `json:"location,omitempty" yaml:"location,omitempty"`
	Tags     map[string]string `json:"tags,omitempty" yaml:"tags,omitempty"`
	Metadata map[string]string `json:"metadata,omitempty" yaml:"metadata,omitempty"`
}

type BucketStat

type BucketStat struct {
	Name        string  `json:"name"`
	ObjectCount int64   `json:"object_count"`
	TotalSize   int64   `json:"total_size"`
	Percentage  float64 `json:"percentage,omitempty"`
}

type CompareDiff

type CompareDiff struct {
	Key        string `json:"key"`
	SourceSize int64  `json:"source_size"`
	DestSize   int64  `json:"dest_size"`
}

type CompareResult

type CompareResult struct {
	OnlyInSource  []string      `json:"only_in_source"`
	OnlyInDest    []string      `json:"only_in_dest"`
	DifferentSize []CompareDiff `json:"different_size"`
	Same          []string      `json:"same"`
}

type OutputResponse

type OutputResponse struct {
	Success bool        `json:"success"`
	Message string      `json:"message,omitempty"`
	Data    interface{} `json:"data,omitempty"`
	Error   string      `json:"error,omitempty"`
	DryRun  bool        `json:"dry_run,omitempty"`
}

OutputResponse represents a standard response format

type Presenter added in v0.28.2

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

Presenter renders command output in the active output mode (FEAT-040).

It exists to collapse the per-command `if JSONOutput { ... } else { ... }` duplication (618 sites at audit time) into one unconditional call per concern. Commands build one presenter per run and call Error/Result without branching on the mode themselves.

Contracts preserved from the legacy branches:

  • Error (plain): returns a formatted error — the command exits non-zero.
  • Error (JSON): prints the standard error envelope and returns printErrorJSON's result (nil when the print succeeds — the historical exit-0-in-JSON-mode behavior; changing that is a separate decision).
  • Result (JSON): marshals data; the human renderer is NEVER invoked in JSON mode so tables never pollute machine-readable stdout.

func NewPresenter added in v0.28.2

func NewPresenter() *Presenter

NewPresenter captures the output mode at construction time. Construct it after flag parsing (inside RunE), not at init time.

func (*Presenter) Error added in v0.28.2

func (p *Presenter) Error(format string, args ...any) error

Error renders a command error in the active mode.

func (*Presenter) ErrorWrap added in v0.28.2

func (p *Presenter) ErrorWrap(msg string, err error) error

ErrorWrap renders a wrapped upstream error (the `%w` legacy shape) in the active mode: "msg: err" both ways, %w-preserved for errors.Is/As in plain mode.

func (*Presenter) IsJSON added in v0.28.2

func (p *Presenter) IsJSON() bool

IsJSON reports whether the presenter runs in machine mode.

func (*Presenter) Result added in v0.28.2

func (p *Presenter) Result(data any, human func()) error

Result renders a success payload: data marshalled in JSON mode, the human renderer invoked in plain mode. Returns the print error, if any.

func (*Presenter) Success added in v0.28.2

func (p *Presenter) Success(message string, data any) error

Success renders a human success message, or the standard success envelope in JSON mode.

func (*Presenter) SuccessPayload added in v0.28.2

func (p *Presenter) SuccessPayload(message string, json func() any, human func()) error

SuccessPayload collapses the shaped-payload species: the json closure builds the command's typed output and is invoked ONLY in JSON mode (the standard success envelope wraps it); the human renderer runs ONLY in plain mode. Both closures stay at the call site, the mode branch lives here — once.

type SSLStatusSection

type SSLStatusSection struct {
	Active   int    `json:"active"`
	Pending  int    `json:"pending"`
	Inactive int    `json:"inactive"`
	Error    string `json:"error,omitempty"`
}

type StatusReport

type StatusReport struct {
	Timestamp   string           `json:"timestamp"`
	AccountID   string           `json:"account_id"`
	Zones       StatusSection    `json:"zones"`
	Workers     StatusSection    `json:"workers"`
	KV          StatusSection    `json:"kv_namespaces"`
	Buckets     StatusSection    `json:"r2_buckets"`
	DNS         StatusSection    `json:"dns_records"`
	SSL         SSLStatusSection `json:"ssl"`
	QueryTimeMs int64            `json:"query_time_ms"`
	Errors      []string         `json:"errors,omitempty"`
}

type StatusSection

type StatusSection struct {
	Count int    `json:"count"`
	Error string `json:"error,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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