cmdutil

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: MIT Imports: 20 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 AutoSaveTrackerConfig added in v0.13.0

func AutoSaveTrackerConfig(parsed *tracker.ParsedURL, configDir string) error

AutoSaveTrackerConfig ensures the parsed tracker URL is represented in .humanconfig.yaml. If the config file doesn't exist, it creates one. If it exists, it appends the tracker entry if not already present.

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 InstanceFromURL added in v0.13.0

func InstanceFromURL(parsed *tracker.ParsedURL) (*tracker.Instance, bool)

InstanceFromURL attempts to build a tracker Instance from a parsed URL using environment variable credentials. Returns (instance, true) if credentials are available and the instance was built. Returns (zero, false) if credentials are missing.

func LoadAllInstances

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

LoadAllInstances collects tracker instances from all provider configs.

func LoadNotionIndexInstances added in v0.13.0

func LoadNotionIndexInstances(dir string) ([]index.NotionInstance, error)

LoadNotionIndexInstances loads Notion instances and converts them to index.NotionInstance for use by the indexer.

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 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.

func WarnSkippedTrackers added in v0.13.0

func WarnSkippedTrackers(w io.Writer, dir string, loaded []tracker.Instance) bool

WarnSkippedTrackers checks which trackers are configured in .humanconfig but did not produce loaded instances (typically due to missing credentials) and writes diagnostic messages to w. Returns true if any trackers were skipped.

Types

type AutoResult added in v0.13.0

type AutoResult struct {
	Provider tracker.Provider
	Kind     string
	Key      string // resolved key (= input if key, = extracted key if URL)
	Cleanup  func()
}

AutoResult holds the resolved provider and extracted key from ResolveAutoProvider.

func ResolveAutoProvider

func ResolveAutoProvider(ctx context.Context, cmd *cobra.Command, input string, allowFindFallback bool, deps Deps) (*AutoResult, 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.

When input is a URL, it parses the URL to extract kind, base URL, and key, then tries to match an existing config instance or build one from env vars.

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