cli

package
v0.10.0 Latest Latest
Warning

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

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

Documentation

Overview

Package cli implements the command-line interface for speedgrapher using Cobra.

Index

Constants

View Source
const AppName = "speedgrapher"

AppName is the root command executable name.

View Source
const DefaultJSONConfig = `` /* 232-byte string literal not displayed */

DefaultJSONConfig is the JSON configuration template.

View Source
const DefaultYAMLConfig = `` /* 1118-byte string literal not displayed */

DefaultYAMLConfig is the master configuration template.

View Source
const MinimalJSONConfig = `{
  "tools": {
    "fog": true,
    "slop": true,
    "seo": true,
    "vale": true
  }
}
`

MinimalJSONConfig is the minimal JSON configuration template.

View Source
const MinimalYAMLConfig = `` /* 405-byte string literal not displayed */

MinimalYAMLConfig is the minimal configuration template.

Variables

This section is empty.

Functions

func ExecuteInstall

func ExecuteInstall(opts InstallOptions, stdout, stderr io.Writer) error

ExecuteInstall performs the installation according to the given options.

func ExecuteUninstall

func ExecuteUninstall(opts UninstallOptions, stdout, stderr io.Writer) error

ExecuteUninstall performs the uninstallation according to the given options.

func ExtractVersion added in v0.10.0

func ExtractVersion(text string, re *regexp.Regexp) string

ExtractVersion searches text using regex and returns the first capture group.

func FormatStatusTable added in v0.10.0

func FormatStatusTable(statuses []ToolStatus) string

FormatStatusTable renders a formatted table suitable for terminal display.

func NewRootCmd added in v0.10.0

func NewRootCmd(version string, stdin io.Reader, stdout, stderr io.Writer) *cobra.Command

NewRootCmd constructs the main Cobra command tree following GoDoctor's CLI design.

func PrintHelp

func PrintHelp(w io.Writer, version string)

PrintHelp writes the main help text to w for backward compatibility.

func Run

func Run(ctx context.Context, version string, args []string, stdin io.Reader, stdout, stderr io.Writer) error

Run executes the CLI with the given arguments and streams.

func Satisfies added in v0.10.0

func Satisfies(installed Version, constraint string) bool

Satisfies determines if installed version satisfies the constraint.

Types

type CheckRunner added in v0.10.0

type CheckRunner interface {
	LookPath(file string) (string, error)
	RunCommand(ctx context.Context, name string, args ...string) ([]byte, error)
}

CheckRunner abstracts command execution and path lookups for testability.

type Checker added in v0.10.0

type Checker struct {
	// contains filtered or unexported fields
}

Checker coordinates inspecting external dependencies.

func NewChecker added in v0.10.0

func NewChecker(runner CheckRunner) *Checker

NewChecker creates a Checker instance with the given runner (or stdCheckRunner if nil).

func (*Checker) CheckAll added in v0.10.0

func (c *Checker) CheckAll(ctx context.Context, specs ...ToolSpec) ([]ToolStatus, error)

CheckAll evaluates all specs.

func (*Checker) CheckTool added in v0.10.0

func (c *Checker) CheckTool(ctx context.Context, spec ToolSpec) (ToolStatus, error)

CheckTool inspects a single tool spec.

type GlobalOptions added in v0.10.0

type GlobalOptions struct {
	ConfigPath string
	Verbose    bool
	Quiet      bool
}

GlobalOptions holds global CLI flags.

type InstallOptions

type InstallOptions struct {
	InstallAll    bool
	InstallMCP    bool
	InstallSkills bool
	Workspace     bool
	Global        bool
	Force         bool
	Quiet         bool
	ConfigPath    string
	SkillsDir     string
}

InstallOptions holds parsed options for the install command.

type Status added in v0.10.0

type Status string

Status represents the health status of an external dependency.

const (
	// StatusOk indicates the tool is installed and meets or exceeds recommended version.
	StatusOk Status = "OK"
	// StatusOutdated indicates the installed version is older than recommended.
	StatusOutdated Status = "OUTDATED"
	// StatusMissing indicates the tool was not found in $PATH.
	StatusMissing Status = "MISSING"
	// StatusUnknown indicates the tool is present but its version could not be parsed.
	StatusUnknown Status = "UNKNOWN"
)

type ToolDef

type ToolDef struct {
	Name        string
	Aliases     []string
	Description string
	Usage       string
	Invoke      func(ctx context.Context, rawArgs []string, stdin io.Reader) (*mcp.CallToolResult, error)
}

ToolDef represents metadata and invoker for a tool.

func FindTool

func FindTool(name string) *ToolDef

FindTool looks up a tool by name or alias.

func GetTools

func GetTools() []ToolDef

GetTools returns the list of all registered tools.

type ToolSpec added in v0.10.0

type ToolSpec struct {
	ID                 string         `json:"id"`
	DisplayName        string         `json:"display_name"`
	Binaries           []string       `json:"binaries"`
	VersionArgs        [][]string     `json:"version_args"`
	OutputRegex        *regexp.Regexp `json:"-"`
	DefaultRecommended string         `json:"default_recommended"`
	Category           string         `json:"category"`
	Required           bool           `json:"required"`
	InstallGuide       string         `json:"install_guide"`
	UpgradeCommand     string         `json:"upgrade_command"`
	Timeout            time.Duration  `json:"timeout,omitempty"`
}

ToolSpec defines inspection metadata and upgrade guidance for an external utility.

func DefaultCheckRegistry added in v0.10.0

func DefaultCheckRegistry() []ToolSpec

DefaultCheckRegistry returns the catalog of external dependencies checked by Speedgrapher.

type ToolStatus added in v0.10.0

type ToolStatus struct {
	ID                 string `json:"id"`
	DisplayName        string `json:"display_name"`
	Status             Status `json:"status"` // OK, OUTDATED, MISSING, UNKNOWN
	BinaryPath         string `json:"binary_path,omitempty"`
	InstalledVersion   string `json:"installed_version,omitempty"`
	RecommendedVersion string `json:"recommended_version"`
	Satisfies          bool   `json:"satisfies"`
	UpgradeCommand     string `json:"upgrade_command,omitempty"`
	Category           string `json:"category,omitempty"`
	Required           bool   `json:"required"`
}

ToolStatus represents the evaluation result of an external utility.

type UninstallOptions

type UninstallOptions struct {
	UninstallAll    bool
	UninstallMCP    bool
	UninstallSkills bool
	Workspace       bool
	Global          bool
	Quiet           bool
	ConfigPath      string
	SkillsDir       string
}

UninstallOptions holds parsed options for the uninstall command.

type Version added in v0.10.0

type Version struct {
	Raw        string
	Major      int
	Minor      int
	Patch      int
	Prerelease string
	IsDevel    bool
}

Version models a parsed semantic version string.

func ParseVersion added in v0.10.0

func ParseVersion(vStr string) Version

ParseVersion converts raw version strings into a structured Version.

func (Version) Compare added in v0.10.0

func (v Version) Compare(target Version) int

Compare compares version v to target (-1 if v < target, 0 if v == target, +1 if v > target).

Jump to

Keyboard shortcuts

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