cmdmeta

package
v0.270.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: MIT Imports: 3 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 cmdmeta attaches machine-readable metadata to cobra commands and flags, so tooling (the command catalog) can describe the CLI without parsing help text.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Enum

func Enum(f *pflag.Flag) []string

Enum returns the flag's accepted values, or nil when it has none recorded.

func Leaves

func Leaves(root *cobra.Command) []*cobra.Command

Leaves returns the commands an agent can run: runnable, non-hidden commands under root, skipping cobra's help and completion commands. Pure groups (a runnable parent that only prints help and carries no metadata) are left out. A parent that carries metadata is kept, since it does real work itself: a TUI entry point such as bare `ofga`, or `model test` with its subcommands.

func Set

func Set(cmd *cobra.Command, m Meta) *cobra.Command

Set writes all four metadata annotations on cmd and returns it.

func SetEnum

func SetEnum(cmd *cobra.Command, flag string, values ...string)

SetEnum records the closed set of values flag accepts. The flag must exist and the set must not be empty.

Types

type Meta

type Meta struct {
	// RequiresStore: the command resolves a store ID from --store-id, the
	// environment or the profile, and fails without one. An ID taken as a
	// positional argument (stores delete <store-id>) is part of the usage
	// instead and doesn't count.
	RequiresStore bool
	// RequiresModel: the same for a model ID and --model-id. A command that
	// falls back to the latest model is false, as is one that takes the ID
	// as a positional argument (model get <model-id>).
	RequiresModel bool
	// Mutates: the command changes server state (stores, models, tuples,
	// assertions), local CLI config or files in the working tree (such as a
	// scaffolded workspace). An output file the caller names with a flag such
	// as --output-file or --cursor-file doesn't count. Dry runs and
	// unconfirmed runs still count as mutating commands.
	Mutates bool
	// InteractiveOnly: the command is a TUI entry point.
	InteractiveOnly bool
}

Meta describes what a leaf command needs and does.

func Get

func Get(cmd *cobra.Command) (Meta, bool)

Get reads the metadata back. ok is false when any key is missing or malformed.

Jump to

Keyboard shortcuts

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