cmd

package
v0.0.0-...-c40c2f6 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2026 License: Unlicense Imports: 55 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RootCmd = &cobra.Command{
	Use:   "tk",
	Short: "tk - system-wide event-sourced task tracker",
	Long:  `tk is a command-line tool that tracks tasks system-wide using an append-only event log in a single SQLite database.`,
	PersistentPreRun: func(cmd *cobra.Command, args []string) {
		if debugFlag {
			slog.SetDefault(slog.New(
				devslog.NewHandler(os.Stderr, &devslog.Options{
					HandlerOptions:  &slog.HandlerOptions{Level: slog.LevelDebug},
					NewLineAfterLog: true,
				}),
			))
			slog.Debug("debug logging enabled")
		}
	},

	Args: cobra.ArbitraryArgs,
	RunE: func(cmd *cobra.Command, args []string) error {

		if len(args) > 0 && len(args[0]) > 0 && args[0][0] == '/' {

			return queryCmd.RunE(cmd, args)
		}

		return cmd.Help()
	},
}

Functions

func ApplySeeAlso

func ApplySeeAlso(cmd *cobra.Command)

ApplySeeAlso adds "See Also" sections to commands based on the registry. It recursively applies to all subcommands as well.

This should be called once on the root command after all commands have been registered.

By default, this shows just command names. To include descriptions from each command's Short field, change the function call from:

SeeAlso(related...)

to:

SeeAlsoWithDescriptions(cmd.Root(), related...)

func IngestRemote

func IngestRemote(db *database.DB, remoteName string, remoteConfig config_pkg.RemoteConfig) error

IngestRemote is kept for backward compatibility with cmd/sync.go New code should use remote.IngestRemote directly

func LoadJSON

func LoadJSON[T any](path string) (*T, error)

LoadJSON loads a JSON file into a struct

func PrintDoctorReport

func PrintDoctorReport(w io.Writer, report *DoctorReport)

func SaveJSON

func SaveJSON[T any](path string, data *T) error

SaveJSON saves a struct to a JSON file

func SeeAlso

func SeeAlso(commands ...string) string

SeeAlso formats a "See Also" section for command help text. It takes a list of command paths and returns a formatted string that can be appended to a command's Long field.

By default, this only shows command names. To include descriptions from Cobra commands, use SeeAlsoWithDescriptions instead.

func SeeAlsoWithDescriptions

func SeeAlsoWithDescriptions(root *cobra.Command, commands ...string) string

SeeAlsoWithDescriptions formats a "See Also" section with descriptions pulled from the Cobra command's Short field.

This avoids duplication by reusing the descriptions already defined in each command. Commands that don't exist or have no Short description will be shown without a description.

func TestColorizeStatus

func TestColorizeStatus(t *testing.T)

func TestExtractPrefix

func TestExtractPrefix(t *testing.T)

func TestGetCurrentUser

func TestGetCurrentUser(t *testing.T)

func ValidateSeeAlso

func ValidateSeeAlso(root *cobra.Command) error

ValidateSeeAlso checks that all commands referenced in the registry actually exist in the command tree.

This function is intended for use in tests only, not at runtime. It uses Cobra's Find() method to verify command existence.

Returns an error if any referenced command doesn't exist, or if a source command in the registry doesn't exist.

Types

type ColumnConstraints

type ColumnConstraints struct {
	TermWidth      int
	ShowAliases    bool
	LabelsMaxWidth int
	TitleMinWidth  int
	SeparatorWidth int // Width of " │ " separator between columns
	PaddingPerCell int // Additional padding within each cell
}

ColumnConstraints defines the constraints for column sizing

func DefaultColumnConstraints

func DefaultColumnConstraints(termWidth int, showAliases bool) ColumnConstraints

DefaultColumnConstraints returns sensible defaults

type ColumnWidths

type ColumnWidths struct {
	ID         int
	Aliases    int
	Kind       int
	Status     int
	Priority   int
	Labels     int
	Title      int
	HasAliases bool
}

ColumnWidths holds the calculated widths for table columns

func CalculateColumnWidths

func CalculateColumnWidths(tasks []*types.Task, displayIDs map[string]string, constraints ColumnConstraints) ColumnWidths

CalculateColumnWidths computes optimal column widths based on actual task data

type ContainerKindExport

type ContainerKindExport struct {
	Name        string  `json:"name"`
	Description *string `json:"description,omitempty"`
}

ContainerKindExport represents a container kind in the export

type DoctorCollision

type DoctorCollision struct {
	ProjectUID     string
	ProjectAlias   string
	Number         int64
	TaskDisplayIDs []string
}

func GetNumberCollisions

func GetNumberCollisions(db *database.DB, projectFilter string) ([]DoctorCollision, error)

GetNumberCollisions finds task number collisions (exported for cmd package)

type DoctorReport

type DoctorReport struct {
	Issues        []string
	InvalidEvents []string
	Collisions    []DoctorCollision
}

func RunDoctor

func RunDoctor(db *database.DB) (*DoctorReport, error)

func (*DoctorReport) ProblemCount

func (r *DoctorReport) ProblemCount() int

type SchemaExport

type SchemaExport struct {
	QueueKinds []ContainerKindExport `json:"queue_kinds"`
	StackKinds []ContainerKindExport `json:"stack_kinds"`
	GroupKinds []ContainerKindExport `json:"group_kinds"`
}

SchemaExport represents the exported schema structure

Jump to

Keyboard shortcuts

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