Documentation
¶
Index ¶
- Variables
- func ApplyBindings(cmd *cobra.Command, bindings []FlagBinding)
- func ApplyTransform(value any, transform string, args map[string]any) (any, error)
- func BuildDynamicCommands(servers []market.ServerDescriptor, runner executor.Runner, ...) []*cobra.Command
- func CollectBindings(cmd *cobra.Command, bindings []FlagBinding, existing map[string]any) (map[string]any, error)
- func MoveParam(params map[string]any, from, to string)
- func MustString(params map[string]any, key string) (string, error)
- func NewCuratedCommand(route Route, runner executor.Runner) *cobra.Command
- func NewDirectCommand(route Route, runner executor.Runner) *cobra.Command
- func NewFallbackCommands(runner executor.Runner) []*cobra.Command
- func NewPublicCommands(runner executor.Runner) []*cobra.Command
- func RegisterFallback(factory CommandFactory)
- func RegisterPublic(factory CommandFactory)
- func ServerEndpoints(servers []market.ServerDescriptor) map[string]string
- func ServerProductIDs(servers []market.ServerDescriptor) map[string]bool
- type CommandFactory
- type FlagBinding
- type Normalizer
- type Route
- type Target
- type ValueKind
Constants ¶
This section is empty.
Variables ¶
var NewGroupCommand = cobracmd.NewGroupCommand
NewGroupCommand delegates to cobracmd.NewGroupCommand for backward compatibility.
Functions ¶
func ApplyBindings ¶
func ApplyBindings(cmd *cobra.Command, bindings []FlagBinding)
func ApplyTransform ¶
ApplyTransform applies a named transform rule to a value. Supported transforms: iso8601_to_millis, csv_to_array, json_parse, json_parse_strict, enum_map, file_read, invert_bool, parse_bool, string_to_int64.
func BuildDynamicCommands ¶
func BuildDynamicCommands(servers []market.ServerDescriptor, runner executor.Runner, detailsByID map[string][]market.DetailTool, existingTools map[string]map[string]struct{}) []*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.
existingTools maps CLI server ID (slug) → set of tool names that server actually exposes (from the live tools/list cache). When a server's set is present and non-empty, override leaves whose backing MCP tool is missing from it are hidden from `--help` (phantom-command guard). When the set is absent or empty (cold cache, or a server we have no tools snapshot for) the guard does nothing for that server, so an unpopulated cache never blanks the command tree. Pass nil to disable the guard entirely.
Conversion rules reference: docs/mcp-to-cli-conversion.md
func CollectBindings ¶
func NewCuratedCommand ¶
NewCuratedCommand creates a DirectCommand with override priority so it wins over auto-generated MCP overlay commands during command tree merging.
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 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
// PipelineLocal, when true, marks this binding as CLI-side only — its
// value is consumed by the pipeline executor (e.g. as an HTTP
// download destination) and NOT forwarded to any MCP tool's params.
PipelineLocal bool
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 Route ¶
type Route struct {
Use string
Aliases []string
Short string
Long string
Example string
Hidden bool
Target Target
Bindings []FlagBinding
// Pipeline, when non-empty, replaces the single-tool dispatch with a
// multi-step orchestration. NewDirectCommand sees this and wires the
// pipeline executor into RunE instead of the standard
// invoke-then-output flow. See internal/compat/pipeline.go.
Pipeline []market.PipelineStep
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
// RejectPositional forces cobra.NoArgs on the generated leaf when no
// positional bindings exist, so stray positional tokens (e.g.
// `dws contact label list unexpected`) exit non-zero. Sourced from
// CLIToolOverride.RejectPositional. Ignored when the leaf already
// declares positional bindings — their arity validator wins.
RejectPositional bool
// RequireTogether groups flag aliases that must all be set together (or
// all left unset). Each inner slice produces one PreRunE cross-field
// check. Sourced from CLIToolOverride.RequireTogether. Unknown flag
// names are logged and skipped at command-build time (consistent with
// applyFlagConstraints semantics).
RequireTogether [][]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" )