cli

package
v0.0.0-...-c964ea2 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: MIT Imports: 31 Imported by: 0

Documentation

Overview

Package cli defines the cobra command tree for the dp CLI.

Index

Constants

This section is empty.

Variables

View Source
var (
	Version = ""
	Commit  = ""
)

Version and Commit are set at build time via -ldflags.

go build -ldflags "-X github.com/scbrown/desire-path/internal/cli.Version=v0.2.0
  -X github.com/scbrown/desire-path/internal/cli.Commit=48cae1d"

Functions

func Execute

func Execute() error

Execute runs the root command.

Types

type AliasCollection

type AliasCollection struct {
	Meta    CollectionMeta  `json:"meta" toml:"meta"`
	Aliases []ExportedAlias `json:"aliases" toml:"aliases"`
}

AliasCollection is the portable interchange format for aliases.

type CollectionMeta

type CollectionMeta struct {
	Version     int       `json:"version" toml:"version"`
	Name        string    `json:"name,omitempty" toml:"name,omitempty"`
	Description string    `json:"description,omitempty" toml:"description,omitempty"`
	Author      string    `json:"author,omitempty" toml:"author,omitempty"`
	ExportedAt  time.Time `json:"exported_at" toml:"exported_at"`
	Source      string    `json:"source,omitempty" toml:"source,omitempty"`
	Count       int       `json:"count" toml:"count"`
}

CollectionMeta holds metadata about an alias collection.

type EnvNeed

type EnvNeed struct {
	Command   string `json:"command"`
	Count     int    `json:"count"`
	LastError string `json:"last_error"`
}

EnvNeed represents an aggregated missing-command need.

type ExportedAlias

type ExportedAlias struct {
	From      string `json:"from" toml:"from"`
	To        string `json:"to" toml:"to"`
	Tool      string `json:"tool,omitempty" toml:"tool,omitempty"`
	Param     string `json:"param,omitempty" toml:"param,omitempty"`
	Command   string `json:"command,omitempty" toml:"command,omitempty"`
	MatchKind string `json:"match_kind,omitempty" toml:"match_kind,omitempty"`
	Message   string `json:"message,omitempty" toml:"message,omitempty"`
}

ExportedAlias is the portable representation of an alias. CreatedAt is omitted — it gets set on import.

type Table

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

Table writes column-aligned output using text/tabwriter with consistent formatting across all commands. Headers are bold when output is a TTY.

func NewTable

func NewTable(w io.Writer, headers ...string) *Table

NewTable creates a Table that writes to w. If headers are provided, they are written as a bold header row (bold only when w is a TTY).

func (*Table) Bold

func (t *Table) Bold(s string) string

Bold wraps text in ANSI bold if color is enabled for this table.

func (*Table) Color

func (t *Table) Color() bool

Color reports whether color output is enabled.

func (*Table) Flush

func (t *Table) Flush() error

Flush flushes the underlying tabwriter.

func (*Table) Row

func (t *Table) Row(vals ...string)

Row writes a data row with tab-separated values.

func (*Table) Width

func (t *Table) Width() int

Width returns the detected terminal width. Returns defaultTermWidth (80) when output is not a TTY.

Jump to

Keyboard shortcuts

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