cmdutil

package
v0.12.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuditLogPath

func AuditLogPath() string

AuditLogPath returns the path to the audit log file (~/.human/audit.log), creating the directory if needed.

func InstanceFromFlags

func InstanceFromFlags(cmd *cobra.Command) *tracker.Instance

InstanceFromFlags builds a tracker instance from root persistent flags, returning nil when insufficient flags are provided.

func LoadAllInstances

func LoadAllInstances(dir string) ([]tracker.Instance, error)

LoadAllInstances collects tracker instances from all provider configs.

func PrintConnectedTrackers

func PrintConnectedTrackers(w io.Writer, loader func() ([]tracker.Instance, error))

PrintConnectedTrackers appends a "Connected trackers:" section to the help output. Errors are silently ignored so that help always works.

func PrintExamples

func PrintExamples(w io.Writer)

PrintExamples prints the quick command and provider examples.

func PrintJSON

func PrintJSON(w io.Writer, v any) error

PrintJSON encodes v as indented JSON to w.

func ResolveAutoProvider

func ResolveAutoProvider(ctx context.Context, cmd *cobra.Command, keyHint string, allowFindFallback bool, deps Deps) (tracker.Provider, string, func(), error)

ResolveAutoProvider loads all instances, applies flag overrides, and resolves the provider without requiring a fixed kind. It uses tracker.Resolve for auto-detection and falls back to FindTracker + ResolveByKind for ambiguous get commands.

func ResolveProvider

func ResolveProvider(cmd *cobra.Command, kind string, deps Deps) (tracker.Provider, func(), error)

ResolveProvider loads instances, applies CLI flag overrides, and resolves the provider for the given kind using the tracker name from persistent flags.

func SetupHelp

func SetupHelp(rootCmd *cobra.Command, loader func() ([]tracker.Instance, error))

SetupHelp overrides the root command's help function to append examples and connected trackers when showing root-level help.

func SplitIDs

func SplitIDs(ids string) []string

SplitIDs splits a comma-separated string into trimmed, non-empty parts.

Types

type Deps

type Deps struct {
	LoadInstances     func(dir string) ([]tracker.Instance, error)
	InstanceFromFlags func(cmd *cobra.Command) *tracker.Instance
	AuditLogPath      func() string
}

Deps holds injectable dependencies for command builders that need tracker instance loading and resolution.

func DefaultDeps

func DefaultDeps() Deps

DefaultDeps returns a Deps using the real implementations.

Jump to

Keyboard shortcuts

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