commands

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultListTimeout is the timeout for listing features.
	// This operation reads all feature files and could be slow with many features.
	DefaultListTimeout = 30 * time.Second

	// DefaultSearchTimeout is the timeout for search operations.
	// This includes fuzzy matching across all features.
	DefaultSearchTimeout = 30 * time.Second

	// DefaultExportTimeout is the timeout for export operations.
	// This reads all features and converts them to the export format.
	DefaultExportTimeout = 60 * time.Second

	// DefaultImportTimeout is the timeout for import operations.
	// This reads external files and creates features.
	DefaultImportTimeout = 60 * time.Second

	// DefaultValidateTimeout is the timeout for validation operations.
	// This validates all features and their relationships.
	DefaultValidateTimeout = 60 * time.Second
)

Default operation timeouts. These can be overridden via environment variables or config in the future.

Variables

View Source
var (
	// Version is the semantic version (e.g., "1.0.0")
	Version = "dev"
	// Commit is the git commit SHA
	Commit = "none"
	// Date is the build date
	Date = "unknown"
)

Build information - injected via ldflags at build time

Functions

func BuildVersion

func BuildVersion() string

BuildVersion returns the full version string

func Execute

func Execute() error

Execute runs the root command

func ExecuteContext

func ExecuteContext(ctx context.Context) error

ExecuteContext runs the root command with the provided context. This enables signal handling for graceful shutdown - when the context is canceled (e.g., via Ctrl+C), the cancellation propagates to all commands via cmd.Context().

func ExecuteRootCmd added in v1.0.2

func ExecuteRootCmd() error

ExecuteRootCmd executes the root command with the given arguments. This is for testing purposes - it ensures proper cleanup of directory state. Tests should use this instead of rootCmd.Execute() directly.

func FindFeatureCrossBranch added in v1.0.8

func FindFeatureCrossBranch(ctx context.Context, cmdCtx *CommandContext, identifier string, suggestCmd string) (*fogit.Feature, error)

FindFeatureCrossBranch finds a feature using cross-branch discovery in branch-per-feature mode. Falls back to current-branch-only search in trunk-based mode or if git is not available.

func FindFeatureCrossBranchWithResult added in v1.0.8

func FindFeatureCrossBranchWithResult(ctx context.Context, cmdCtx *CommandContext, identifier string, suggestCmd string) (*features.CrossBranchFindResult, error)

FindFeatureCrossBranchWithResult is like FindFeatureCrossBranch but returns the full result including branch information. Use this when you need to know which branch a feature is on.

func FindFeatureForCommand added in v1.4.1

func FindFeatureForCommand(ctx context.Context, cmdCtx *CommandContext, identifier string, suggestCmd string) (*fogit.Feature, error)

FindFeatureForCommand finds a feature using cross-branch discovery (in branch-per-feature mode) with suggestion support. This is the recommended function for all commands that look up features.

func FindFeatureWithSuggestions

func FindFeatureWithSuggestions(ctx context.Context, repo fogit.Repository, identifier string, cfg *fogit.Config, suggestCmd string) (*fogit.Feature, error)

FindFeatureWithSuggestions finds a feature by ID/name and handles error display with suggestions. DEPRECATED: Use FindFeatureCrossBranch instead for cross-branch discovery support. This function only searches the current branch.

func GetConfig

func GetConfig() *fogit.Config

GetConfig returns the loaded global config (available to all commands)

func ListFeaturesCrossBranch added in v1.0.8

func ListFeaturesCrossBranch(ctx context.Context, cmdCtx *CommandContext, filter *fogit.Filter) ([]*fogit.Feature, error)

ListFeaturesCrossBranch lists all features using cross-branch discovery in branch-per-feature mode. Falls back to current-branch-only listing in trunk-based mode or if git is not available.

func RegisterFilterFlags

func RegisterFilterFlags(cmd *cobra.Command, flags *CommonFilterFlags)

RegisterFilterFlags adds common filter flags to a command. These flags are used by list, search, and other filter-based commands.

Usage:

var filterFlags CommonFilterFlags
func init() {
    RegisterFilterFlags(myCmd, &filterFlags)
}

func RegisterFormatFlag

func RegisterFormatFlag(cmd *cobra.Command, format *string)

RegisterFormatFlag adds only the format flag to a command. Use this when sort is not needed (e.g., search command).

func RegisterOrganizationFlags

func RegisterOrganizationFlags(cmd *cobra.Command, flags *OrganizationFlags)

RegisterOrganizationFlags adds organization-related flags to a command. These flags are used by list, update, and feature commands.

func RegisterOutputFlags

func RegisterOutputFlags(cmd *cobra.Command, flags *OutputFlags)

RegisterOutputFlags adds output formatting flags to a command. These flags are used by list, search, show, and other output commands.

func ResetFlags added in v1.0.2

func ResetFlags()

ResetFlags resets global flags to their default values. This is useful for testing where flags may persist between test runs.

func WithExportTimeout

func WithExportTimeout(parent context.Context) (context.Context, context.CancelFunc)

WithExportTimeout creates a context with the default export operation timeout.

func WithImportTimeout

func WithImportTimeout(parent context.Context) (context.Context, context.CancelFunc)

WithImportTimeout creates a context with the default import operation timeout.

func WithListTimeout

func WithListTimeout(parent context.Context) (context.Context, context.CancelFunc)

WithListTimeout creates a context with the default list operation timeout.

func WithSearchTimeout

func WithSearchTimeout(parent context.Context) (context.Context, context.CancelFunc)

WithSearchTimeout creates a context with the default search operation timeout.

func WithTimeout

func WithTimeout(parent context.Context, timeout time.Duration) (context.Context, context.CancelFunc)

WithTimeout creates a child context with the specified timeout. It returns the context, a cancel function that should be deferred, and handles the case where the parent context is nil.

Usage:

ctx, cancel := WithTimeout(cmd.Context(), DefaultListTimeout)
defer cancel()

func WithValidateTimeout

func WithValidateTimeout(parent context.Context) (context.Context, context.CancelFunc)

WithValidateTimeout creates a context with the default validation operation timeout.

Types

type CommandContext

type CommandContext struct {
	FogitDir string
	Repo     fogit.Repository
	Config   *fogit.Config
	Git      *features.GitIntegration // nil if not in git repo
}

CommandContext holds common dependencies for commands

func GetCommandContext

func GetCommandContext() (*CommandContext, error)

GetCommandContext initializes all common dependencies for a command This reduces boilerplate in individual commands

func GetCommandContextWithoutConfig

func GetCommandContextWithoutConfig() (*CommandContext, error)

GetCommandContextWithoutConfig initializes dependencies without loading config Useful for commands that don't need configuration

type CommonFilterFlags

type CommonFilterFlags struct {
	State    string
	Priority string
	Type     string
	Category string
}

CommonFilterFlags holds values for common filter flags used across commands.

type GitHubUpdater

type GitHubUpdater struct{}

GitHubUpdater is the real implementation using go-selfupdate

func (*GitHubUpdater) DetectLatest

func (g *GitHubUpdater) DetectLatest(ctx context.Context, slug string) (*Release, bool, error)

func (*GitHubUpdater) UpdateTo

func (g *GitHubUpdater) UpdateTo(ctx context.Context, release *Release, cmdPath string) error

type OrganizationFlags

type OrganizationFlags struct {
	Domain string
	Team   string
	Epic   string
}

OrganizationFlags holds values for organization-related flags.

type OutputFlags

type OutputFlags struct {
	Format string
	Sort   string
}

OutputFlags holds values for output formatting flags.

type RelationshipCategoryExport

type RelationshipCategoryExport struct {
	Description     string `json:"description,omitempty" yaml:"description,omitempty"`
	AllowCycles     bool   `json:"allow_cycles" yaml:"allow_cycles"`
	CycleDetection  string `json:"cycle_detection" yaml:"cycle_detection"`
	IncludeInImpact bool   `json:"include_in_impact" yaml:"include_in_impact"`
}

RelationshipCategoryExport represents a category in the export format

type RelationshipExport

type RelationshipExport struct {
	FogitVersion           string                                `json:"fogit_version" yaml:"fogit_version"`
	ExportedAt             string                                `json:"exported_at" yaml:"exported_at"`
	Repository             string                                `json:"repository,omitempty" yaml:"repository,omitempty"`
	RelationshipCategories map[string]RelationshipCategoryExport `json:"relationship_categories,omitempty" yaml:"relationship_categories,omitempty"`
	RelationshipTypes      map[string]RelationshipTypeExport     `json:"relationship_types,omitempty" yaml:"relationship_types,omitempty"`
}

RelationshipExport represents the export schema for relationship definitions

type RelationshipTypeExport

type RelationshipTypeExport struct {
	Category      string   `json:"category" yaml:"category"`
	Description   string   `json:"description,omitempty" yaml:"description,omitempty"`
	Inverse       string   `json:"inverse,omitempty" yaml:"inverse,omitempty"`
	Bidirectional bool     `json:"bidirectional,omitempty" yaml:"bidirectional,omitempty"`
	Aliases       []string `json:"aliases,omitempty" yaml:"aliases,omitempty"`
}

RelationshipTypeExport represents a type in the export format

type Release

type Release struct {
	Version   string
	AssetURL  string
	AssetName string
}

Release holds version info (abstraction over selfupdate.Release)

func (*Release) LessOrEqual

func (r *Release) LessOrEqual(version string) bool

LessOrEqual checks if this release version is less than or equal to the given version

type Updater

type Updater interface {
	DetectLatest(ctx context.Context, slug string) (*Release, bool, error)
	UpdateTo(ctx context.Context, release *Release, cmdPath string) error
}

Updater interface for dependency injection (enables testing)

Jump to

Keyboard shortcuts

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