shared

package
v0.0.0-...-13cc935 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package shared contains a slim set of helpers used across the surviving subcommands (aso, completion, docs). Anything App Store Connect specific has been removed; this package now deals only with output formatting, usage rendering, terminal sanitization, and CI report flags.

Index

Constants

View Source
const ReportFormatJUnit = "junit"

ReportFormatJUnit is the only supported value for --report.

Variables

View Source
var ErrMissingAuth = errors.New("missing authentication")

ErrMissingAuth is returned by commands that require authentication.

Functions

func BindCIFlags

func BindCIFlags(fs *flag.FlagSet)

BindCIFlags registers --report and --report-file.

func BindRootFlags

func BindRootFlags(fs *flag.FlagSet)

BindRootFlags registers root-level flags.

func Bold

func Bold(s string) string

Bold wraps the string in ANSI bold codes when the terminal supports color.

func CleanupTempPrivateKeys

func CleanupTempPrivateKeys()

CleanupTempPrivateKeys is a no-op in the slim build but kept to preserve the Run() entrypoint signature.

func ContextWithTimeout

func ContextWithTimeout(ctx context.Context) (context.Context, context.CancelFunc)

ContextWithTimeout returns the context unchanged in the slim build. It exists so callers that previously relied on ASC_TIMEOUT can keep their signatures.

func DefaultUsageFunc

func DefaultUsageFunc(c *ffcli.Command) string

DefaultUsageFunc is the standard help renderer used by survivor commands.

func NewReportedError

func NewReportedError(err error) error

NewReportedError wraps an already-printed error.

func PrintOutput

func PrintOutput(data any, format string, pretty bool) error

PrintOutput renders data in the requested format. Only "json" is supported in the slim build for arbitrary structures; "table" and "markdown" require callers to use PrintOutputWithRenderers.

func PrintOutputWithRenderers

func PrintOutputWithRenderers(data any, format string, pretty bool, tableRenderer, markdownRenderer func() error) error

PrintOutputWithRenderers prints JSON directly or invokes the supplied table/markdown renderer.

func ReportFile

func ReportFile() string

ReportFile returns the configured report file path.

func ReportFormat

func ReportFormat() string

ReportFormat returns the configured report format.

func SanitizeTerminal

func SanitizeTerminal(input string) string

SanitizeTerminal strips control characters to prevent escape injection.

func SelectedProfile

func SelectedProfile() string

SelectedProfile returns the current profile override.

func SetReportFile

func SetReportFile(v string)

SetReportFile sets the report file path (testing).

func SetReportFormat

func SetReportFormat(v string)

SetReportFormat sets the report format (testing).

func SetSelectedProfile

func SetSelectedProfile(value string)

SetSelectedProfile sets the profile (tests only).

func UsageError

func UsageError(message string) error

UsageError prints an error to stderr and returns flag.ErrHelp so the run loop maps it to the usage exit code.

func ValidateBoundOutputFlags

func ValidateBoundOutputFlags(fs *flag.FlagSet) error

ValidateBoundOutputFlags checks the validators registered on flagsets.

func ValidateReportFlags

func ValidateReportFlags() error

ValidateReportFlags validates the CI report flags.

func WrapCommandOutputValidation

func WrapCommandOutputValidation(cmd *ffcli.Command)

WrapCommandOutputValidation wraps a command (and its subcommands) so invalid output-format flag values fail before Exec runs.

Types

type JUnitReport

type JUnitReport struct {
	Tests     []JUnitTestCase
	Timestamp time.Time
	Name      string
}

JUnitReport represents a JUnit XML report.

func (*JUnitReport) Marshal

func (r *JUnitReport) Marshal() ([]byte, error)

Marshal renders the report as XML bytes.

func (*JUnitReport) Write

func (r *JUnitReport) Write(path string) error

Write writes the JUnit report to a file.

type JUnitTestCase

type JUnitTestCase struct {
	Name      string
	Classname string
	Time      time.Duration
	Failure   string
	Message   string
	SystemOut string
	SystemErr string
}

JUnitTestCase represents a single test case in a JUnit report.

type OutputFlags

type OutputFlags struct {
	Output *string
	Pretty *bool
}

OutputFlags stores pointers to output-related flag values.

func BindOutputFlags

func BindOutputFlags(fs *flag.FlagSet) OutputFlags

BindOutputFlags registers --output and --pretty.

type ReportedError

type ReportedError interface {
	error
	Reported() bool
}

ReportedError marks errors already printed to the user; the Run loop should avoid double-reporting them.

Directories

Path Synopsis
Package errfmt formats errors for stderr output.
Package errfmt formats errors for stderr output.
Package suggest produces near-match command suggestions for typos.
Package suggest produces near-match command suggestions for typos.

Jump to

Keyboard shortcuts

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