shared

package
v0.182.6 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package shared defines the small contracts used by independent CLI families. It does not construct commands or perform domain operations.

Index

Constants

View Source
const (
	ExitFindings = 1
	ExitUsage    = 2
)
View Source
const (
	DefaultCIWaitSlice = 8 * time.Minute
)

Variables

View Source
var ExactGitObjectID = regexp.MustCompile(`^[0-9a-fA-F]{40}([0-9a-fA-F]{24})?$`)

Functions

func AddJSONFormatFlags

func AddJSONFormatFlags(command *cobra.Command, jsonOut *bool)

AddJSONFormatFlags gives commands with a JSON output mode one canonical selector and keeps --json as an exact, order-aware shortcut. Both flags write the same value, so --json is equivalent to --format=json and --json=false is equivalent to --format=text.

func ArgumentOrCurrent

func ArgumentOrCurrent(args []string) string

func HumanAge

func HumanAge(d time.Duration) string

func OutputFormatChanged

func OutputFormatChanged(command *cobra.Command) bool

func PublishedAgo

func PublishedAgo(value string) string

func RequireOutputFormat

func RequireOutputFormat(value string, allowed ...string) error

RequireOutputFormat checks an exact format name and explains the accepted spellings. It preserves the CLI's existing format diagnostic.

func SelectJSONFormat

func SelectJSONFormat(format string, jsonOut bool) (string, error)

SelectJSONFormat preserves the independent --format/--json selector contract.

func ShellQuoteArg

func ShellQuoteArg(value string) string

func ShortPath

func ShortPath(path string) string

func ValidateBranchChoice

func ValidateBranchChoice(branch string, branchChosen, prefixChosen bool) error

ValidateBranchChoice validates explicit branch choices without altering their values.

func WriteFormat

func WriteFormat(writer io.Writer, format string, values ...any) error

func WriteLine

func WriteLine(writer io.Writer, values ...any) error

Types

type Flags

type Flags struct {
	ProjectsRoot   string
	Filter         string
	ExtraOrgs      []string
	NonInteractive bool
	Quiet          bool
}

Flags is a snapshot of invocation-wide options. Families read only the fields they consume; the root registry remains responsible for persistent flag policy.

type Runtime

type Runtime struct {
	Flags     func() Flags
	ExitError func(code int, message string) error
}

Runtime connects a family to invocation-wide policy without importing the executable package. Flags must be read during command execution, after parsing. ExitError preserves the executable's coded-error identity and classification.

Jump to

Keyboard shortcuts

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