Documentation
¶
Index ¶
- Constants
- func AddJSONFieldsFlag(cmd *cobra.Command, target *string)
- func AddListFlags(cmd *cobra.Command, flags *ListFlags, defaultLimit int)
- func AddPlainFlags(cmd *cobra.Command, flags *ListFlags)
- func AddViewFlags(cmd *cobra.Command, opts *ViewOptions)
- func BuildResultError(p *output.Printer, client api.ClientInterface, build *api.Build, ...) error
- func FormatAgentStatus(a api.Agent) string
- func NotAuthenticatedError(serverURL string, keyringErr error) *tcerrors.UserError
- func ParseID(s string, entity string) (int, error)
- func PrintFailureSummary(p *output.Printer, client api.ClientInterface, ...)
- func ProbeGuestAccess(serverURL string) bool
- func ResolveAgent(client api.ClientInterface, nameOrID string) (*api.Agent, error)
- func ResolveAgentID(client api.ClientInterface, nameOrID string) (int, string, error)
- func RunList(f *Factory, cmd *cobra.Command, flags *ListFlags, fieldSpec *api.FieldSpec, ...) error
- func SubcommandRequired(cmd *cobra.Command, args []string) error
- func ValidateLimit(limit int) error
- type ExitError
- type Factory
- type IOStreams
- type JSONFieldsResult
- type ListFlags
- type ListResult
- type ListTable
- type ViewOptions
Constants ¶
const ( ExitFailure = 1 ExitCancelled = 2 ExitTimeout = 124 )
Variables ¶
This section is empty.
Functions ¶
func AddJSONFieldsFlag ¶
AddJSONFieldsFlag adds a --json flag that accepts optional field specification
func AddListFlags ¶
AddListFlags registers --limit, --json, --plain, and --no-header flags on a command.
func AddPlainFlags ¶ added in v0.8.3
AddPlainFlags registers --plain and --no-header flags on a command. Use this for list commands that already register --json separately.
func AddViewFlags ¶
func AddViewFlags(cmd *cobra.Command, opts *ViewOptions)
AddViewFlags adds --json and --web flags to a command.
func BuildResultError ¶
func BuildResultError(p *output.Printer, client api.ClientInterface, build *api.Build, showDetails bool) error
BuildResultError prints the final build result and returns an appropriate exit error. Used by both the standard watch and TUI watch paths.
func FormatAgentStatus ¶
FormatAgentStatus returns a formatted status string for an agent.
func NotAuthenticatedError ¶
NotAuthenticatedError returns a not-authenticated error with a hint that covers all authentication methods: environment variables, interactive login, and guest access.
func PrintFailureSummary ¶
func PrintFailureSummary(p *output.Printer, client api.ClientInterface, buildID, buildNumber, webURL, statusText string)
func ProbeGuestAccess ¶
ProbeGuestAccess checks whether the server at serverURL supports guest access.
func ResolveAgent ¶
ResolveAgent resolves an agent name or ID to an Agent object.
func ResolveAgentID ¶
ResolveAgentID resolves an agent name or ID to a numeric agent ID and name.
func RunList ¶
func RunList( f *Factory, cmd *cobra.Command, flags *ListFlags, fieldSpec *api.FieldSpec, fetch func(client api.ClientInterface, fields []string) (*ListResult, error), ) error
RunList handles the shared boilerplate for list commands: limit validation, JSON field parsing, client creation, fetch, and output.
func SubcommandRequired ¶
SubcommandRequired is a RunE function for parent commands that require a subcommand. It returns an error when no valid subcommand is provided.
func ValidateLimit ¶
ValidateLimit returns an error if limit is not positive.
Types ¶
type ExitError ¶
type ExitError struct {
Code int
}
ExitError is returned by commands that need a specific exit code.
type Factory ¶
type Factory struct {
// Global flags — set once by root command, read by subcommands.
NoColor bool
Quiet bool
Verbose bool
NoInput bool
// IOStreams provides standard I/O handles. Override in tests to capture output.
IOStreams *IOStreams
// Printer writes formatted output. Prefer this over the output package
// free functions — it uses the Factory's IOStreams and respects Quiet/Verbose
// without relying on package globals.
Printer *output.Printer
// ClientFunc returns an API client. Override in tests to inject mocks.
ClientFunc func() (api.ClientInterface, error)
// UpdateNotice is called after command execution to print update notices.
UpdateNotice func()
}
Factory provides shared dependencies to all commands. Instead of reaching for package-level globals, commands receive a Factory and use its methods/fields to get clients, check flags, etc.
func (*Factory) Client ¶
func (f *Factory) Client() (api.ClientInterface, error)
Client returns an API client using the configured ClientFunc.
func (*Factory) InitOutput ¶
func (f *Factory) InitOutput()
InitOutput configures output settings from Factory flags. Called once after flags are parsed (in PersistentPreRun).
func (*Factory) IsInteractive ¶
IsInteractive returns true if the CLI can prompt the user.
func (*Factory) WarnInsecureHTTP ¶
WarnInsecureHTTP prints a warning to stderr when connecting over plain HTTP.
type IOStreams ¶
IOStreams provides the standard streams for commands to read/write. Commands should use these instead of os.Stdin/os.Stdout/os.Stderr directly, enabling tests to capture output without redirecting globals.
type JSONFieldsResult ¶
JSONFieldsResult represents the parsed result of --json flag
type ListResult ¶
ListResult is returned by a list command's fetch function. Set either JSON (for JSON output) or Table (for table output).
type ViewOptions ¶
ViewOptions is shared by view commands that support JSON and web output.