props

package
v1.0.3 Latest Latest
Warning

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

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

README

Props

The core dependency injection container for GTB applications.

Props holds global state including:

  • Tool metadata
  • Logger instance
  • Configuration container
  • Filesystem abstraction (Afero)
  • Version information

For detailed documentation on design rationale and usage patterns, see the Props Component Documentation.

Documentation

Index

Constants

View Source
const (
	UpdateCmd = FeatureCmd("update")
	InitCmd   = FeatureCmd("init")
	McpCmd    = FeatureCmd("mcp")
	DocsCmd   = FeatureCmd("docs")
	AiCmd     = FeatureCmd("ai")
)

Variables

DefaultFeatures is the list of features enabled by default.

Functions

This section is empty.

Types

type AssetMap

type AssetMap map[string]fs.FS

AssetMap is a custom type for a map of filesystems.

type Assets

type Assets interface {
	fs.FS
	fs.ReadDirFS
	fs.GlobFS
	fs.StatFS

	Slice() []fs.FS
	Names() []string
	Get(name string) fs.FS
	Register(name string, fs fs.FS)
	For(names ...string) Assets
	Merge(others ...Assets) Assets
	Exists(name string) (fs.FS, error)
	Mount(f fs.FS, prefix string)
}

Assets is an interface that wraps a map of fs.FS pointers and implements the standard fs interfaces.

func NewAssets

func NewAssets(assets ...AssetMap) Assets

NewAssets creates a new Assets wrapper with the given AssetMap pointers.

type Feature

type Feature struct {
	Cmd     FeatureCmd `json:"cmd" yaml:"cmd"`
	Enabled bool       `json:"enabled" yaml:"enabled"`
}

Feature represents the state of a feature (Enabled/Disabled).

func SetFeatures

func SetFeatures(mutators ...FeatureState) []Feature

SetFeatures applies a series of mutators to the standard default set.

type FeatureCmd

type FeatureCmd string

type FeatureState

type FeatureState func([]Feature) []Feature

FeatureState is a functional option that mutates the list of features.

func Disable

func Disable(cmd FeatureCmd) FeatureState

Disable returns a FeatureState that disables the given command.

func Enable

func Enable(cmd FeatureCmd) FeatureState

Enable returns a FeatureState that enables the given command.

type Props

type Props struct {
	Tool         Tool
	Logger       *log.Logger
	Config       config.Containable
	Assets       Assets
	FS           afero.Fs
	Version      version.Version
	ErrorHandler errorhandling.ErrorHandler
}

type ReleaseSource

type ReleaseSource struct {
	Type  string `json:"type" yaml:"type"`
	Host  string `json:"host" yaml:"host"`
	Owner string `json:"owner" yaml:"owner"`
	Repo  string `json:"repo" yaml:"repo"`
}

type Tool

type Tool struct {
	Name        string                   `json:"name" yaml:"name"`
	Summary     string                   `json:"summary" yaml:"summary"`
	Description string                   `json:"description" yaml:"description"`
	Features    []Feature                `json:"features" yaml:"features"`
	Help        errorhandling.HelpConfig `json:"-" yaml:"-"`

	// ReleaseSource is the source of truth for the tool's releases (GitHub or GitLab)
	ReleaseSource ReleaseSource `json:"release_source" yaml:"release_source"`

	// Deprecated: Use Features instead
	Disable []FeatureCmd `json:"disable" yaml:"disable"`
	// Deprecated: Use Features instead
	Enable []FeatureCmd `json:"enable" yaml:"enable"`
}

func (Tool) GetReleaseSource

func (t Tool) GetReleaseSource() (sourceType, owner, repo string)

GetReleaseSource returns the release source type, owner, and repo.

func (Tool) IsDisabled

func (t Tool) IsDisabled(cmd FeatureCmd) bool

IsDisabled checks if a feature is disabled.

func (Tool) IsEnabled

func (t Tool) IsEnabled(cmd FeatureCmd) bool

IsEnabled checks if a feature is enabled. It prioritizes the new Features slice, falling back to Disable/Enable slices for backward compatibility, and finally falling back to the built-in defaults.

Jump to

Keyboard shortcuts

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