command

package
v0.3.0 Latest Latest
Warning

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

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

Documentation

Overview

Package command provides CLI commands for the jay application.

Package command provides CLI commands for the jay application.

Index

Constants

View Source
const (
	AppEmoji        = "🍒"
	ApplicationName = "jay"
	SourceID        = "github.com/snivilised/jaywalk/src/agenor"
)
View Source
const (
	// root
	RootPsName = "root-ps"

	// shared families (registered on root, inherited by sub-commands)
	PreviewFamName     = "preview-fam"
	CascadeFamName     = "cascade-fam"
	InteractionFamName = "interaction-fam"
	SamplingFamName    = "sampling-fam"

	// run-only family
	WorkerPoolFamName = "worker-pool-fam"

	// filter family (registered per-command, not inherited)
	PolyFamName = "poly-fam"

	// jay-specific param sets
	WalkPsName = "walk-ps"
	RunPsName  = "run-ps"
)
View Source
const (
	ResumeStrategySpawn    = "spawn"
	ResumeStrategyFastward = "fastward"
)
View Source
const (
	// SubscribeFlagFiles subscribes to file nodes only.
	SubscribeFlagFiles = "files"

	// SubscribeFlagDirs subscribes to directory nodes only.
	SubscribeFlagDirs = "dirs"

	// SubscribeFlagAll subscribes to all nodes (files and directories).
	SubscribeFlagAll = "all"

	// SubscribeFlagDefault is the default subscription if not specified.
	SubscribeFlagDefault = SubscribeFlagAll
)

Variables

View Source
var (
	Version = strings.TrimSpace(version)
)

TODO: The version.txt should be updated in ci to contain the version number associated with the applied tag. Currently not yet defined in this template.

Functions

func Execute

func Execute() error

func ResolveSubscription

func ResolveSubscription(flag string) (enums.Subscription, error)

ResolveSubscription maps the user-supplied --subscribe string to the corresponding agenor enums.Subscription value. Returns an error if the value is not one of the three legal strings.

Types

type Bootstrap

type Bootstrap struct {

	// Cfg is populated after configure() reads viper.
	Cfg *cfg.Config

	// UI is constructed from the --tui flag value in PersistentPreRunE
	// and injected into every command's Inputs struct.
	UI ui.Manager
	// contains filtered or unexported fields
}

Bootstrap constructs the full cobra command tree and owns all mamba param-set registrations. It is the single entry point for application startup wiring.

func (*Bootstrap) Root

func (b *Bootstrap) Root(options ...ConfigureOptionFn) *cobra.Command

Root builds the command tree and returns the root command, ready to be executed.

type ConfigInfo

type ConfigInfo struct {
	Name       string
	ConfigType string
	ConfigPath string
	Viper      macfg.ViperConfig
}

ConfigInfo describes the configuration file that should be loaded, including its name, type, path and the viper instance to use.

type ConfigureOptionFn

type ConfigureOptionFn func(*ConfigureOptions)

ConfigureOptionFn is a functional option used to modify ConfigureOptions before Bootstrap performs its setup.

type ConfigureOptions

type ConfigureOptions struct {
	Detector LocaleDetector
	Config   ConfigInfo
}

ConfigureOptions groups configuration options that influence how Bootstrap initialises localisation and configuration.

type Jabber

type Jabber struct{}

Jabber is a LocaleDetector implemented using jibberjabber.

func (*Jabber) Scan

func (j *Jabber) Scan() language.Tag

Scan returns the detected language tag.

type LocaleDetector

type LocaleDetector interface {
	Scan() language.Tag
}

LocaleDetector abstracts the detection of the user's preferred language as a BCP 47 language tag.

type RootParameterSet

type RootParameterSet struct {
	store.ParameterSetWithOverrides

	// Language sets the IETF BCP 47 language tag for i18n output.
	Language string

	// TUI selects the display mode. Corresponds to --tui <mode>.
	// Defaults to "linear" (plain fmt.Println output).
	// Future values: "flashy", "retro", etc (Charm-based implementations).
	TUI string
}

RootParameterSet holds flags defined on the root command that are inherited by all sub-commands.

type RunInputs

type RunInputs struct {
	SharedFamilies

	// Tree is the positional directory argument.
	Tree string

	// UI is the display manager selected by --tui. All output to the
	// terminal is routed through this interface.
	UI ui.Manager

	// Jay-specific flags
	ParamSet *assist.ParamSet[RunParameterSet]

	// Per-command filter family (not inherited from root)
	PolyFam *assist.ParamSet[store.PolyFilterParameterSet]

	// Run-only family
	WorkerPool *assist.ParamSet[store.WorkerPoolParameterSet]
}

RunInputs collects all flag values needed to build a Run invocation.

type RunParameterSet

type RunParameterSet struct {
	store.ParameterSetWithOverrides

	// Subscribe controls which node types are visited.
	// Valid values: "files", "dirs", "all". Maps to --subscribe(-s).
	Subscribe string

	// Action names the config-defined action to invoke for each node.
	// Maps to --action(-a).
	Action string

	// Pipeline names the config-defined pipeline to execute.
	// Maps to --pipeline(-p).
	Pipeline string

	// Resume defines the resume strategy to use when re-entering a
	// previously interrupted traversal. Maps to --resume(-r).
	// Valid values: "spawn", "fastward". Empty means prime (no resume).
	Resume string
}

RunParameterSet holds the jay-specific flags for the run command. It mirrors WalkParameterSet; run additionally gets WorkerPoolParameterSet via a separate family registration.

type SharedFamilies

SharedFamilies groups the mamba param-set pointers registered on the root command as persistent flags, inherited by all sub-commands. Note: CliInteractionParameterSet is NOT included here because --tui is a string flag on RootParameterSet, allowing the user to select a named display mode rather than a simple on/off boolean.

type WalkInputs

type WalkInputs struct {
	SharedFamilies

	// Tree is the positional directory argument.
	Tree string

	// UI is the display manager selected by --tui. All output to the
	// terminal is routed through this interface.
	UI ui.Manager

	// Jay-specific flags
	ParamSet *assist.ParamSet[WalkParameterSet]

	// Per-command filter family (not inherited from root)
	PolyFam *assist.ParamSet[store.PolyFilterParameterSet]
}

WalkInputs collects all flag values needed to build a Walk invocation.

type WalkParameterSet

type WalkParameterSet struct {
	store.ParameterSetWithOverrides

	// Subscribe controls which node types are visited.
	// Valid values: "files", "dirs", "all". Maps to --subscribe(-s).
	Subscribe string

	// Action names the config-defined action to invoke for each node.
	// Maps to --action(-a).
	Action string

	// Pipeline names the config-defined pipeline to execute.
	// Maps to --pipeline(-p).
	Pipeline string

	// Resume defines the resume strategy to use when re-entering a
	// previously interrupted traversal. Maps to --resume(-r).
	// Valid values: "spawn", "fastward". Empty means prime (no resume).
	Resume string
}

WalkParameterSet holds the jay-specific flags for the walk command. Shared families (preview, cascade, sampling, poly-filter) are registered separately and are not embedded here.

Directories

Path Synopsis
internal
cfg
Package cfg handles all configuration concerns for jay, including loading, validation, and access to config values.
Package cfg handles all configuration concerns for jay, including loading, validation, and access to config values.

Jump to

Keyboard shortcuts

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