cli

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: GPL-3.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Error

func Error(text string) string

func Execute

func Execute() error

func Info

func Info(text string) string

func Primary

func Primary(text string) string

func ResolveProjectContext

func ResolveProjectContext(homeDir, repoDir, projectFlag string) (*project.ProjectEntry, error)

ResolveProjectContext finds the active project using the --project flag or the current repo's .git/.hourgit config.

func SetVersionInfo

func SetVersionInfo(version string)

func Silent

func Silent(text string) string

func Text

func Text(text string) string

func Warning

func Warning(text string) string

Types

type BoolFlag

type BoolFlag struct {
	Name      string
	Shorthand string
	Usage     string
	Default   bool
}

BoolFlag defines a boolean flag for a command.

type ConfirmFunc

type ConfirmFunc func(prompt string) (bool, error)

ConfirmFunc prompts the user for confirmation and returns true if confirmed.

func AlwaysYes

func AlwaysYes() ConfirmFunc

AlwaysYes returns a ConfirmFunc that always confirms.

func NewConfirmFunc

func NewConfirmFunc() ConfirmFunc

NewConfirmFunc creates a ConfirmFunc using huh's interactive confirm component.

func ResolveConfirmFunc

func ResolveConfirmFunc(yes bool) ConfirmFunc

ResolveConfirmFunc returns AlwaysYes() if yes is true, otherwise NewConfirmFunc().

type GitReflogFunc

type GitReflogFunc func(repoDir string, since *time.Time) (string, error)

GitReflogFunc executes git reflog and returns its output. The since parameter is non-nil when LastSync is available.

type GroupCommand

type GroupCommand struct {
	Use         string
	Short       string
	Subcommands []*cobra.Command
}

GroupCommand defines a command that only holds subcommands.

func (GroupCommand) Build

func (gc GroupCommand) Build() *cobra.Command

Build creates a cobra.Command with all subcommands registered.

type LeafCommand

type LeafCommand struct {
	Use       string
	Short     string
	Args      cobra.PositionalArgs
	BoolFlags []BoolFlag
	StrFlags  []StringFlag
	RunE      func(cmd *cobra.Command, args []string) error
}

LeafCommand defines a command that executes logic. Every leaf command file must declare one of these and call Build().

func (LeafCommand) Build

func (lc LeafCommand) Build() *cobra.Command

Build creates a cobra.Command with all flags registered.

type MultiSelectFunc

type MultiSelectFunc func(title string, options []string) ([]int, error)

MultiSelectFunc prompts the user to select multiple options. Returns 0-based indices.

func NewMultiSelectFunc

func NewMultiSelectFunc() MultiSelectFunc

NewMultiSelectFunc creates a MultiSelectFunc using huh's interactive multi-select component.

type ProjectEntries added in v0.8.0

type ProjectEntries struct {
	Checkouts      []entry.CheckoutEntry
	Logs           []entry.Entry
	Commits        []entry.CommitEntry
	ActivityStops  []entry.ActivityStopEntry
	ActivityStarts []entry.ActivityStartEntry
}

ProjectEntries holds all entry types for a project.

func LoadProjectEntries added in v0.8.0

func LoadProjectEntries(homeDir, slug string) (ProjectEntries, error)

LoadProjectEntries reads all 5 entry types for a project in one call.

type PromptFunc

type PromptFunc func(prompt string) (string, error)

PromptFunc prompts the user for free-text input and returns the response.

func NewPromptFunc

func NewPromptFunc() PromptFunc

NewPromptFunc creates a PromptFunc using huh's interactive input component.

type PromptKit

type PromptKit struct {
	Prompt            PromptFunc
	PromptWithDefault PromptWithDefaultFunc
	Confirm           ConfirmFunc
	Select            SelectFunc
	MultiSelect       MultiSelectFunc
}

PromptKit bundles all prompt function types for dependency injection.

func NewPromptKit

func NewPromptKit() PromptKit

NewPromptKit creates a PromptKit with huh-based interactive implementations.

type PromptWithDefaultFunc

type PromptWithDefaultFunc func(prompt, defaultValue string) (string, error)

PromptWithDefaultFunc prompts the user for input with a pre-filled default value.

func NewPromptWithDefaultFunc

func NewPromptWithDefaultFunc() PromptWithDefaultFunc

NewPromptWithDefaultFunc creates a PromptWithDefaultFunc using huh's interactive input.

type SelectFunc

type SelectFunc func(title string, options []string) (int, error)

SelectFunc prompts the user to select one option from a list. Returns 0-based index.

func NewSelectFunc

func NewSelectFunc() SelectFunc

NewSelectFunc creates a SelectFunc using huh's interactive select component.

func ResolveSelectFunc

func ResolveSelectFunc(yes bool) SelectFunc

ResolveSelectFunc returns a SelectFunc that always picks the first option if yes is true, otherwise returns an interactive SelectFunc.

type StringFlag

type StringFlag struct {
	Name      string
	Shorthand string
	Usage     string
	Default   string
}

StringFlag defines a string flag for a command.

Jump to

Keyboard shortcuts

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