compat

package
v1.0.20 Latest Latest
Warning

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

Go to latest
Published: May 4, 2026 License: Apache-2.0 Imports: 24 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

Index

Constants

This section is empty.

Variables

View Source
var NewGroupCommand = cobracmd.NewGroupCommand

NewGroupCommand delegates to cobracmd.NewGroupCommand for backward compatibility.

Functions

func ApplyBindings

func ApplyBindings(cmd *cobra.Command, bindings []FlagBinding)

func ApplyTransform

func ApplyTransform(value any, transform string, args map[string]any) (any, error)

ApplyTransform applies a named transform rule to a value. Supported transforms: iso8601_to_millis, csv_to_array, json_parse, enum_map.

func BuildDynamicCommands

func BuildDynamicCommands(servers []market.ServerDescriptor, runner executor.Runner, detailsByID map[string][]market.DetailTool) []*cobra.Command

BuildDynamicCommands generates cobra commands from servers.json CLIOverlay metadata. Each server with non-skip CLIOverlay gets a top-level command with groups and tool overrides translated into subcommands with proper flag bindings and transforms.

detailsByID maps CLI server ID → []DetailTool from the MCP Detail API. When provided, tool Short/Long descriptions and typed flags are enriched from Detail API data.

Conversion rules reference: docs/mcp-to-cli-conversion.md

func CollectBindings

func CollectBindings(cmd *cobra.Command, bindings []FlagBinding, existing map[string]any) (map[string]any, error)

func MoveParam

func MoveParam(params map[string]any, from, to string)

func MustString

func MustString(params map[string]any, key string) (string, error)

func NewCuratedCommand

func NewCuratedCommand(route Route, runner executor.Runner) *cobra.Command

NewCuratedCommand creates a DirectCommand with override priority so it wins over auto-generated MCP overlay commands during command tree merging.

func NewDirectCommand

func NewDirectCommand(route Route, runner executor.Runner) *cobra.Command

func NewFallbackCommands

func NewFallbackCommands(runner executor.Runner) []*cobra.Command

func NewPublicCommands

func NewPublicCommands(runner executor.Runner) []*cobra.Command

func RegisterFallback

func RegisterFallback(factory CommandFactory)

func RegisterPublic

func RegisterPublic(factory CommandFactory)

func ServerEndpoints

func ServerEndpoints(servers []market.ServerDescriptor) map[string]string

ServerEndpoints extracts product ID → endpoint URL mapping from servers.

func ServerProductIDs

func ServerProductIDs(servers []market.ServerDescriptor) map[string]bool

ServerProductIDs extracts the set of product IDs from servers with CLI metadata.

Types

type CommandFactory

type CommandFactory func(runner executor.Runner) *cobra.Command

type FlagBinding

type FlagBinding struct {
	FlagName string
	Alias    string
	// Aliases are additional hidden flag names that map to the same MCP
	// parameter. Any of them being set satisfies Required, and the value
	// is resolved via firstChangedFlag(FlagName, Alias, Aliases...).
	// Mirrors cmdutil.ValidateRequiredFlagWithAliases / FlagOrFallback.
	Aliases  []string
	Short    string
	Property string
	Kind     ValueKind
	Usage    string
	Required bool
	// Default is the cobra-level flag default value as a string. Parsed
	// into the Kind-appropriate primitive at registration time. Empty
	// string keeps the existing zero-value default. This only affects
	// what cobra renders in --help (the "(default ...)" suffix); it does
	// NOT inject the value into MCP params on its own — CollectBindings
	// still gates writes by user-changed flags via firstChangedFlag.
	Default string
	// Positional binds this parameter to a positional CLI argument rather
	// than a --flag. PositionalIndex is the 0-based slot.
	Positional      bool
	PositionalIndex int
}

type Normalizer

type Normalizer func(cmd *cobra.Command, params map[string]any) error

type Route

type Route struct {
	Use        string
	Aliases    []string
	Short      string
	Long       string
	Example    string
	Hidden     bool
	Target     Target
	Bindings   []FlagBinding
	Normalizer Normalizer
	// OutputTransform, when non-nil, post-processes the MCP response payload
	// (rename / drop / columns) before the formatter emits it. Wired up from
	// CLIToolOverride.OutputFormat. See discovery-schema-v3 §2.5.
	OutputTransform func(map[string]any) map[string]any
}

type Target

type Target struct {
	CanonicalProduct string
	Tool             string
}

type ValueKind

type ValueKind string
const (
	ValueString      ValueKind = "string"
	ValueInt         ValueKind = "int"
	ValueFloat       ValueKind = "float"
	ValueBool        ValueKind = "bool"
	ValueStringSlice ValueKind = "string_slice"
	ValueIntSlice    ValueKind = "int_slice"
	ValueFloatSlice  ValueKind = "float_slice"
	ValueBoolSlice   ValueKind = "bool_slice"
	ValueJSON        ValueKind = "json"
)

Jump to

Keyboard shortcuts

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