cli

package
v0.97.12 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package cli provides a thin generic cobra scaffold for building CLI entry points: a root command with common flags (--version, --config) and a subcommand registration helper. No application-specific defaults are baked in — all parameters are supplied by the caller.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRoot

func NewRoot(cfg RootConfig) *cobra.Command

NewRoot builds a generic cobra root command with --version (when Version is set) and a --config flag, ready to have subcommands attached.

func PrintMCPConfig

func PrintMCPConfig(name, url, transport string)

PrintMCPConfig prints a 'claude mcp add' config snippet for the given server name, url and transport to stdout.

func RegisterSubcommand

func RegisterSubcommand(root *cobra.Command, sub SubcommandConfig) *cobra.Command

RegisterSubcommand attaches a subcommand described by sub to root and returns the created command so callers can add flags to it.

Types

type RootConfig

type RootConfig struct {
	Use     string // command usage line, e.g. "myapp"
	Short   string // one-line description
	Long    string // long description
	Version string // value reported by --version; empty disables the flag
	// ConfigFlagName is the name of the config-file flag; defaults to "config".
	ConfigFlagName string
	// Run is the root command's Run function; may be nil for command groups.
	Run func(cmd *cobra.Command, args []string)
}

RootConfig holds parameters for building the root command. All fields are optional except Use.

type SubcommandConfig

type SubcommandConfig struct {
	Name  string
	Short string
	Long  string
	Run   func(cmd *cobra.Command, args []string)
}

SubcommandConfig describes a subcommand to register under a root command.

Jump to

Keyboard shortcuts

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