cli

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 28 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package cli provides the command-line interface for aperturecli.

Index

Constants

View Source
const (
	// ExitSuccess indicates the command completed successfully.
	ExitSuccess = 0

	// ExitGeneralError indicates an unclassified error.
	ExitGeneralError = 1

	// ExitInvalidArgs indicates invalid arguments or validation failure.
	ExitInvalidArgs = 2

	// ExitConnectionError indicates a gRPC connection failure.
	ExitConnectionError = 3

	// ExitAuthFailure indicates a macaroon authentication failure.
	ExitAuthFailure = 4

	// ExitNotFound indicates a requested resource was not found.
	ExitNotFound = 5

	// ExitDryRunPassed indicates a dry-run completed successfully
	// with no action taken.
	ExitDryRunPassed = 10
)

Exit codes for aperturecli. These are semantic exit codes that agents can parse for control flow, going beyond the typical 0/1 binary.

Variables

View Source
var Version = "dev"

Version is set at build time via -ldflags.

Functions

func ErrorKind

func ErrorKind(err error) string

ErrorKind extracts the machine-readable kind string from an error. If the error is not a CLIError, "general_error" is returned.

func ExitCode

func ExitCode(err error) int

ExitCode extracts the exit code from an error. If the error is a CLIError, its Code field is returned. Otherwise 1 (general error) is returned.

func NewHealthCmd

func NewHealthCmd() *cobra.Command

NewHealthCmd creates the health subcommand that checks server health.

func NewInfoCmd

func NewInfoCmd() *cobra.Command

NewInfoCmd creates the info subcommand that displays Aperture server information.

func NewMCPCmd

func NewMCPCmd() *cobra.Command

NewMCPCmd creates the mcp subcommand for Model Context Protocol server operations.

func NewRootCmd

func NewRootCmd() *cobra.Command

NewRootCmd creates the root aperturecli command with all subcommands registered.

func NewSchemaCmd

func NewSchemaCmd() *cobra.Command

NewSchemaCmd creates the schema introspection subcommand. It allows agents to discover the CLI's commands, flags, and types at runtime without parsing --help text.

func NewServicesCmd

func NewServicesCmd() *cobra.Command

NewServicesCmd creates the services parent command with list, create, update, and delete subcommands.

func NewStatsCmd

func NewStatsCmd() *cobra.Command

NewStatsCmd creates the stats subcommand that displays revenue statistics.

func NewTokensCmd

func NewTokensCmd() *cobra.Command

NewTokensCmd creates the tokens parent command with list and revoke subcommands.

func NewTransactionsCmd

func NewTransactionsCmd() *cobra.Command

NewTransactionsCmd creates the transactions parent command.

func WriteErrorJSON

func WriteErrorJSON(w io.Writer, err error)

WriteErrorJSON writes a structured JSON error object to the given writer. This is used by the main entrypoint to emit machine-readable errors on stderr.

Types

type ArgSchema

type ArgSchema struct {
	// Name is the argument name.
	Name string `json:"name"`

	// Required indicates whether the argument is mandatory.
	Required bool `json:"required"`

	// Description explains the argument.
	Description string `json:"description"`
}

ArgSchema describes a positional argument.

type CLIError

type CLIError struct {
	// Code is the process exit code.
	Code int

	// Kind is a machine-readable error classifier such as
	// "invalid_args" or "connection_error".
	Kind string

	// Message is the human-readable error description.
	Message string

	// Inner is the wrapped cause, if any.
	Inner error
}

CLIError is a structured error that carries a semantic exit code and a machine-readable error kind string. The CLI uses this to emit structured JSON error objects on stderr and return the appropriate exit code.

func ErrAuthWrap

func ErrAuthWrap(inner error) *CLIError

ErrAuthWrap wraps an authentication error with the auth_failure exit code.

func ErrConnectionWrap

func ErrConnectionWrap(inner error) *CLIError

ErrConnectionWrap wraps a connection error with the connection_error exit code.

func ErrDryRunPassedNew

func ErrDryRunPassedNew() *CLIError

ErrDryRunPassedNew creates a dry-run-passed indicator. This is not a real error; it signals that the dry-run preview completed successfully with no mutations.

func ErrInvalidArgsf

func ErrInvalidArgsf(format string, args ...any) *CLIError

ErrInvalidArgsf creates an invalid-arguments error with a formatted message.

func ErrNotFoundf

func ErrNotFoundf(format string, args ...any) *CLIError

ErrNotFoundf creates a not-found error with a formatted message.

func NewCLIError

func NewCLIError(code int, kind, message string) *CLIError

NewCLIError creates a new CLIError with the given code, kind, and message.

func WrapCLIError

func WrapCLIError(code int, kind string, inner error) *CLIError

WrapCLIError creates a new CLIError that wraps an existing error.

func (*CLIError) Error

func (e *CLIError) Error() string

Error implements the error interface.

func (*CLIError) Unwrap

func (e *CLIError) Unwrap() error

Unwrap returns the underlying cause for errors.Is/As chains.

type CommandSchema

type CommandSchema struct {
	// Name is the command name (e.g. "services").
	Name string `json:"name"`

	// FullPath is the fully qualified command path
	// (e.g. "aperturecli services list").
	FullPath string `json:"full_path"`

	// Description is the short description of the command.
	Description string `json:"description"`

	// LongDescription is the detailed description, if available.
	LongDescription string `json:"long_description,omitempty"`

	// Args describes the positional arguments.
	Args []ArgSchema `json:"args,omitempty"`

	// Flags lists all flags accepted by this command.
	Flags []FlagSchema `json:"flags,omitempty"`

	// Subcommands lists child commands, if any.
	Subcommands []CommandSchema `json:"subcommands,omitempty"`

	// ExitCodes documents the semantic exit codes.
	ExitCodes map[int]string `json:"exit_codes,omitempty"`
}

CommandSchema is the machine-readable schema for a CLI command, designed for agent introspection via aperturecli schema.

type FlagSchema

type FlagSchema struct {
	// Name is the long flag name (without --).
	Name string `json:"name"`

	// Short is the single-character shorthand, if any.
	Short string `json:"short,omitempty"`

	// Type is the value type (string, bool, int, etc.).
	Type string `json:"type"`

	// Default is the default value as a string.
	Default string `json:"default,omitempty"`

	// Description explains the flag.
	Description string `json:"description"`
}

FlagSchema describes a CLI flag.

Jump to

Keyboard shortcuts

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