cmd

package
v1.0.95 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: MIT Imports: 55 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BootstrapInvocationContext added in v1.0.5

func BootstrapInvocationContext(args []string) (cmdutil.InvocationContext, error)

BootstrapInvocationContext extracts global invocation options before the real command tree is built, so provider-backed config resolution sees the correct profile from the start.

func Build added in v1.0.16

Build constructs the full command tree by default. When WithInvocationArgs is provided, it constructs only the command domains that those arguments can reach and configures Cobra to execute the same arguments.

Build also installs registered plugins and emits the Startup lifecycle event during assembly -- so Plugin.On(Startup) handlers run even if the returned command is never dispatched. The matching Shutdown event is only emitted by Execute; callers that bypass Execute will not see Shutdown fire.

Returns only the cobra.Command; Factory and hook Registry are internal. Use Execute for the standard production entry point.

func Execute

func Execute() int

func ExecuteWithOptions added in v1.0.84

func ExecuteWithOptions(opts ...BuildOption) int

ExecuteWithOptions is the standard entrypoint for wrapper distributions that need host-level Build options such as ConcealRestrictedCommands. Execute intentionally keeps its original non-variadic signature for source compatibility with callers that store it as a func() int value.

func RegisterGlobalFlags added in v1.0.5

func RegisterGlobalFlags(fs *pflag.FlagSet, opts *GlobalOptions)

RegisterGlobalFlags registers the root-level persistent flags on fs and applies any visibility policy encoded in opts. Pure function: no disk, network, or environment reads — the caller decides HideProfile.

func ResolveStartupBrand added in v1.0.69

func ResolveStartupBrand(profile string) core.LarkBrand

ResolveStartupBrand retains the legacy startup-brand resolution order for wrapper mains that still pass its result to WithStartupBrand. Deprecated: committed catalog selection is brand-independent.

func SetDefaultFS added in v1.0.16

func SetDefaultFS(fs vfs.FS)

SetDefaultFS replaces the global filesystem implementation used by internal packages. The provided fs must implement the vfs.FS interface. If fs is nil, the default OS filesystem is restored.

Call this before Build or Execute to take effect.

func SetEmbeddedAffordanceContent added in v1.0.84

func SetEmbeddedAffordanceContent(fsys fs.FS)

SetEmbeddedAffordanceContent registers the per-domain command guidance tree. Wrapper mains should wire the repository's affordance directory alongside embedded skills so generic --help presentation remains complete and skill references follow the composed distribution.

func SetEmbeddedSkillContent added in v1.0.49

func SetEmbeddedSkillContent(fsys fs.FS)

SetEmbeddedSkillContent registers the embedded skill tree. Called from the repo-root package main's init; a wrapper main can call it before Execute to supply its own skill content.

Types

type BuildOption added in v1.0.16

type BuildOption func(*buildConfig)

BuildOption configures optional aspects of the command tree construction.

func ConcealRestrictedCommands added in v1.0.84

func ConcealRestrictedCommands(opts ...RestrictionPresentationOption) BuildOption

ConcealRestrictedCommands opts one command tree into presenting plugin-restricted commands as capabilities absent from the distribution.

Restrict remains the enforcement boundary. Without this BuildOption, existing Restrict plugins keep their established failed_precondition envelope, explicit-help, and completion behavior.

Pass the returned option to Build, or to ExecuteWithOptions when using the standard host entrypoint.

func HideProfile added in v1.0.16

func HideProfile(hide bool) BuildOption

HideProfile sets the visibility policy for the root-level --profile flag. When hide is true the flag stays registered (so existing invocations still parse) but is omitted from help and shell completion. Typically called as HideProfile(isSingleAppMode()).

func WithCommandSets added in v1.0.90

func WithCommandSets(sets ...command.Set) BuildOption

WithCommandSets adds build-time business commands to an independently built CLI. The supplied declarations are copied when this option is created and compiled as one atomic contribution during command-tree construction.

func WithIO added in v1.0.16

func WithIO(in io.Reader, out, errOut io.Writer) BuildOption

WithIO sets the IO streams for the CLI by wrapping raw reader/writers. Terminal detection is delegated to cmdutil.NewIOStreams.

func WithInvocationArgs added in v1.0.95

func WithInvocationArgs(args []string) BuildOption

WithInvocationArgs enables target-aware assembly for Build. The provided arguments are used both to select the Catalog and Shortcut domains and as Cobra's execution arguments, keeping assembly and dispatch on one source of truth. Build remains a full-tree constructor when this option is omitted.

An explicitly empty slice represents a bare invocation and therefore still assembles the complete tree for root help. The slice is copied so later caller mutation cannot change the planned or executed command.

func WithKeychain added in v1.0.16

func WithKeychain(kc keychain.KeychainAccess) BuildOption

WithKeychain sets the secret storage backend. If not provided, the platform keychain is used.

func WithServiceCatalog added in v1.0.56

func WithServiceCatalog(catalog apicatalog.Catalog) BuildOption

WithServiceCatalog uses catalog as the authoritative metadata for the entire command build instead of opening the embedded snapshot. It is primarily intended for deterministic inspection tools and tests.

func WithStartupBrand added in v1.0.69

func WithStartupBrand(_ core.LarkBrand) BuildOption

WithStartupBrand is retained for source compatibility with wrapper mains. Deprecated: the committed API catalog is brand-independent, so this option no longer changes command construction.

func WithoutPlugins added in v1.0.56

func WithoutPlugins() BuildOption

WithoutPlugins builds only repository-owned commands. It is intended for inspection tools that need a deterministic command tree.

func WithoutServiceCommands added in v1.0.56

func WithoutServiceCommands() BuildOption

WithoutServiceCommands builds only hand-authored commands. It is intended for repository quality gates that should not depend on the generated API command surface of the embedded Catalog.

func WithoutStrictMode added in v1.0.56

func WithoutStrictMode() BuildOption

WithoutStrictMode builds the complete repository-owned command tree without applying user/profile strict-mode pruning. It is intended for offline inspection tools, not production execution.

type GlobalOptions added in v1.0.5

type GlobalOptions struct {
	Profile     string
	HideProfile bool
}

GlobalOptions are the root-level flags shared by bootstrap parsing and the actual Cobra command tree. Profile is the parsed --profile value; HideProfile is a build-time policy — when true, --profile stays parseable but is marked hidden from help and shell completion.

type RestrictionPresentationOption added in v1.0.84

type RestrictionPresentationOption func(*restrictionPresentationConfig)

RestrictionPresentationOption configures the presentation of commands denied by an embedded distribution's Restrict plugin.

Values are accepted only by ConcealRestrictedCommands. The pointed-to configuration type is private by design; callers use the constructors in this file instead of depending on a public struct layout.

func HidePolicyDiagnostics added in v1.0.84

func HidePolicyDiagnostics() RestrictionPresentationOption

HidePolicyDiagnostics removes the policy self-inspection commands from a concealed distribution. Without it, those commands remain the operator's recovery and inspection escape hatch.

func UnavailableMessage added in v1.0.84

func UnavailableMessage(message string) RestrictionPresentationOption

UnavailableMessage customizes the error message for a concealed command. An empty message selects the distribution-neutral default.

Directories

Path Synopsis
render
Package render turns consume decisions into user-facing output.
Package render turns consume decisions into user-facing output.
Package skill implements the `lark-cli skills` command group, which serves binary-embedded skill content to AI agents.
Package skill implements the `lark-cli skills` command group, which serves binary-embedded skill content to AI agents.

Jump to

Keyboard shortcuts

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