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 AliasAwareHelp(cmd *cobra.Command, canonical, alias string)
- func BuildResultError(ctx context.Context, p *output.Printer, client api.ClientInterface, ...) error
- func Confirm(title string, value *bool) error
- func DeprecateCommand(cmd *cobra.Command, new, removeVersion string)
- func DeprecateFlag(cmd *cobra.Command, old, new, removeVersion string)
- func FormatAgentStatus(a api.Agent) string
- func MarkExperimental(f *Factory, cmd *cobra.Command)
- func NotAuthenticatedError(ctx context.Context, serverURL string, keyringErr error) *api.ValidationError
- func OpenURLOrWarn(p *output.Printer, url string)
- func ParseID(s string, entity string) (int, error)
- func PrintFailureSummary(ctx context.Context, p *output.Printer, client api.ClientInterface, ...)
- func ProbeGuestAccess(ctx context.Context, serverURL string) bool
- func Prompt(field huh.Field) error
- func PromptOptionalString(p *output.Printer, title, description string, value *string) error
- func PromptSecret(title string, value *string) error
- func PromptString(p *output.Printer, title, description string, value *string) error
- func RequireNonEmpty(s string) error
- 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 Select[T comparable](p *output.Printer, title string, options []huh.Option[T], value *T) error
- func SubcommandRequired(cmd *cobra.Command, args []string) error
- func ValidateLimit(limit int) error
- type ExitError
- type Factory
- func (f *Factory) Client() (api.ClientInterface, error)
- func (f *Factory) Context() context.Context
- func (f *Factory) InitOutput()
- func (f *Factory) IsInteractive() bool
- func (f *Factory) ResolveDefaultJob(explicit string) string
- func (f *Factory) ResolveProject(explicit string) string
- func (f *Factory) SetContext(ctx context.Context)
- func (f *Factory) SkipLinkLookup()
- func (f *Factory) WarnInsecureHTTP(serverURL, credentialType string)
- 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 AliasAwareHelp ¶ added in v0.9.0
AliasAwareHelp makes help output reflect whichever alias the user typed.
func BuildResultError ¶
func BuildResultError(ctx context.Context, 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 Confirm ¶ added in v0.10.0
Confirm asks a yes/no question inline with left-aligned compact buttons.
func DeprecateCommand ¶ added in v0.9.0
DeprecateCommand marks a command as deprecated with a consistent message format.
func DeprecateFlag ¶ added in v0.9.0
DeprecateFlag marks a flag as deprecated with a consistent message format.
func FormatAgentStatus ¶
FormatAgentStatus returns a formatted status string for an agent.
func MarkExperimental ¶ added in v0.9.0
MarkExperimental tags a command as experimental and warns on each invocation.
func NotAuthenticatedError ¶
func NotAuthenticatedError(ctx context.Context, serverURL string, keyringErr error) *api.ValidationError
NotAuthenticatedError returns a not-authenticated error with a hint that covers all authentication methods.
func OpenURLOrWarn ¶ added in v0.10.0
OpenURLOrWarn opens url in the browser, warning on failure. Never returns an error — safe to call after a mutation.
func PrintFailureSummary ¶
func ProbeGuestAccess ¶
ProbeGuestAccess checks whether the server at serverURL supports guest access; honors ctx for cancellation.
func Prompt ¶ added in v0.10.0
Prompt runs a single huh field with the CLI theme; does not echo — use PromptString / Select / Confirm for that.
func PromptOptionalString ¶ added in v0.10.0
PromptOptionalString asks for free-form text without rejecting empty input, useful when blank means "skip".
func PromptSecret ¶ added in v0.10.0
PromptSecret asks for a hidden value and never echoes it back.
func PromptString ¶ added in v0.10.0
PromptString asks for free-form text and echoes the answer back so it survives in scrollback.
func RequireNonEmpty ¶ added in v0.10.0
RequireNonEmpty is a huh validator that rejects empty or whitespace-only input.
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 Select ¶ added in v0.10.0
Select presents a typed picker (filtering auto-enabled for 5+ options) and echoes the picked label back.
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
// JSONOutput is set by commands that accept --json to signal that errors
// should be emitted as structured JSON instead of human-readable text.
JSONOutput 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()
// contains filtered or unexported fields
}
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) Context ¶ added in v0.10.0
Context returns the Factory's root context; use this everywhere in our code rather than cmd.Context().
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) ResolveDefaultJob ¶ added in v0.10.0
ResolveDefaultJob returns explicit, then TEAMCITY_JOB, then scope.Job, then a single Jobs entry.
func (*Factory) ResolveProject ¶ added in v0.10.0
ResolveProject returns explicit, then TEAMCITY_PROJECT, then the linked scope's project.
func (*Factory) SetContext ¶ added in v0.10.0
SetContext installs the signal-cancel root context; cmd.Execute keeps rootCmd's Cobra context in sync as a safety net.
func (*Factory) SkipLinkLookup ¶ added in v0.10.0
func (f *Factory) SkipLinkLookup()
SkipLinkLookup pre-resolves this Factory's link to empty, isolating Resolve* from the host's teamcity.toml.
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). EmptyTip is shown alongside EmptyMsg when the table is empty.
type ViewOptions ¶
ViewOptions is shared by view commands that support JSON and web output.