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
- Variables
- func BindCIFlags(fs *flag.FlagSet)
- func BindRootFlags(fs *flag.FlagSet)
- func Bold(s string) string
- func CleanupTempPrivateKeys()
- func ContextWithTimeout(ctx context.Context) (context.Context, context.CancelFunc)
- func DefaultUsageFunc(c *ffcli.Command) string
- func NewReportedError(err error) error
- func PrintOutput(data any, format string, pretty bool) error
- func PrintOutputWithRenderers(data any, format string, pretty bool, ...) error
- func ReportFile() string
- func ReportFormat() string
- func SanitizeTerminal(input string) string
- func SelectedProfile() string
- func SetReportFile(v string)
- func SetReportFormat(v string)
- func SetSelectedProfile(value string)
- func UsageError(message string) error
- func ValidateBoundOutputFlags(fs *flag.FlagSet) error
- func ValidateReportFlags() error
- func WrapCommandOutputValidation(cmd *ffcli.Command)
- type JUnitReport
- type JUnitTestCase
- type OutputFlags
- type ReportedError
Constants ¶
const ReportFormatJUnit = "junit"
ReportFormatJUnit is the only supported value for --report.
Variables ¶
var ErrMissingAuth = errors.New("missing authentication")
ErrMissingAuth is returned by commands that require authentication.
Functions ¶
func BindCIFlags ¶
BindCIFlags registers --report and --report-file.
func CleanupTempPrivateKeys ¶
func CleanupTempPrivateKeys()
CleanupTempPrivateKeys is a no-op in the slim build but kept to preserve the Run() entrypoint signature.
func ContextWithTimeout ¶
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 ¶
DefaultUsageFunc is the standard help renderer used by survivor commands.
func NewReportedError ¶
NewReportedError wraps an already-printed error.
func PrintOutput ¶
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 SanitizeTerminal ¶
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 ¶
UsageError prints an error to stderr and returns flag.ErrHelp so the run loop maps it to the usage exit code.
func ValidateBoundOutputFlags ¶
ValidateBoundOutputFlags checks the validators registered on flagsets.
func ValidateReportFlags ¶
func ValidateReportFlags() error
ValidateReportFlags validates the CI report flags.
func WrapCommandOutputValidation ¶
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 ¶
OutputFlags stores pointers to output-related flag values.
func BindOutputFlags ¶
func BindOutputFlags(fs *flag.FlagSet) OutputFlags
BindOutputFlags registers --output and --pretty.
type ReportedError ¶
ReportedError marks errors already printed to the user; the Run loop should avoid double-reporting them.