authoringcli

package
v0.0.0-...-cb63059 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package authoringcli constructs fresh, privately wired authoring commands. It contains no project services and is not registered by either released main.

Index

Constants

View Source
const RejectionKey = "authoringcli.v1-rejection"

RejectionKey identifies private, terminal compatibility errors, never jobs.

Variables

This section is empty.

Functions

func CheckReleaseCompletion

func CheckReleaseCompletion(root *cobra.Command, args []string) error

CheckReleaseCompletion preflights Cobra 1.10's getCompletions error paths: command lookup, complete flag values, and the incomplete flag's identity. root is disposable: ParseFlags must never mutate the real completion tree. No command/Args/completion callback is executed and no raw error is exposed.

func NewAuthorCommand

func NewAuthorCommand(factories ...Factory) (*cobra.Command, error)

NewAuthorCommand is internal wiring only: the subtree remains hidden until the integrator explicitly opens the complete vertical-slice release gate. The returned mutable subtree is single-invocation. The installer root retains all existing persistent flags in their positions.

func NewCommand

func NewCommand[Request, Result any](spec Spec[Request, Result]) (*cobra.Command, error)

NewCommand returns a new command and new flag sets on every call. The returned mutable command is single-invocation. Required dependencies fail at construction, so missing services cannot become stubs.

func NewPluginKitRoot

func NewPluginKitRoot(factories ...Factory) (*cobra.Command, error)

NewPluginKitRoot returns a mutable single-invocation root for future composition, not a replacement for v1 yet. Execute it through a Factory.

func NewReleaseAuthorCommand

func NewReleaseAuthorCommand(factories ...Factory) (*cobra.Command, error)

func NewReleasePluginKitRoot

func NewReleasePluginKitRoot(factories ...Factory) (*cobra.Command, error)

func PrepareReleaseUtilities

func PrepareReleaseUtilities(root *cobra.Command, completion bool)

PrepareReleaseUtilities uses Cobra's real tree. Hidden retirement shims are removed before generating scripts, including generators that walk all nodes.

Types

type Factory

type Factory func() (*cobra.Command, error)

Factory must construct a fresh single-invocation tree, including flag bindings and mutable captures, never return a cached Cobra command. Composition must execute through Factory.Execute, including for the enclosing installer root.

func (Factory) Execute

func (factory Factory) Execute(ctx context.Context, args []string, streams Streams) error

Execute builds and consumes a fresh tree for every invocation, including help, parse failures and cancellation. It never resets installer-owned flag values. Factories and injected services must be concurrency-safe if called concurrently.

type Options

type Options struct {
	Format  string
	NoColor bool
	DryRun  bool
	Target  string
}

Options is a value snapshot, never the installer's mutable options object. Target is the explicit comma-separated selection, not detected clients.

func AdaptFlags

func AdaptFlags(cmd *cobra.Command, support Support) (Options, error)

AdaptFlags must run before decoding inputs or invoking any service. Explicit false/empty/default-valued installer flags are still rejected. Unsupported inherited defaults are ignored; explicitly selected unsupported flags fail.

type Runner

type Runner[Request, Result any] interface {
	Run(context.Context, Request) (Result, error)
}

Runner is instantiated with each command's own request and result types. A command never needs an application-wide backend or another command's ports.

type RunnerFunc

type RunnerFunc[Request, Result any] func(context.Context, Request) (Result, error)

func (RunnerFunc[Request, Result]) Run

func (f RunnerFunc[Request, Result]) Run(ctx context.Context, req Request) (Result, error)

type Spec

type Spec[Request, Result any] struct {
	Use, Short, Long string
	Hidden           bool
	Args             cobra.PositionalArgs
	Support          Support
	Configure        func(*cobra.Command)
	Decode           func(*cobra.Command, Options, []string) (Request, error)
	Runner           Runner[Request, Result]
	Render           func(Streams, Options, Result, error) error
}

Spec separates Cobra decoding, the in-process runner, and existing rendering. Configure must register command-local flags without capturing shared mutable variables; Decode reads their values from the supplied command. Render owns the human/JSON contract, including failure reports, and must never prompt in JSON mode. The factory preserves runner errors and their exitx annotations.

type Streams

type Streams struct {
	In       io.Reader
	Out, Err io.Writer
}

Streams belong to the selected command, including parent-provided streams.

type Support

type Support struct{ Format, NoColor, DryRun, Target bool }

Support declares which inherited flags a particular command understands.

Jump to

Keyboard shortcuts

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