config

package
v0.39.2 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const File = ".tagconfig.json"

Variables

This section is empty.

Functions

func CheckConfig

func CheckConfig(cfg *Config) error

CheckConfig validates that a config exists and returns an error if not.

func CreateConfigFile

func CreateConfigFile(opts CreateConfigOptions) error

CreateConfigFile writes a new .tagconfig.json with the given options.

func GlobalConfigPath

func GlobalConfigPath() (string, error)

GlobalConfigPath returns the full path to the global config file.

func SaveGlobalConfig

func SaveGlobalConfig(cfg *GlobalConfig) error

SaveGlobalConfig writes the user-level config to $XDG_CONFIG_HOME/tag/config.json. It creates parent directories as needed.

Types

type Config

type Config struct {
	Template  *TemplateOrigin `json:"template,omitempty"`
	Variables map[string]any  `json:"variables,omitempty"`
	Env       Env             `json:"env"`
	Hooks     Hooks           `json:"hooks"`
}

func LoadConfigFile

func LoadConfigFile(dir string) (*Config, error)

LoadConfigFile loads the configuration from the config file in the given directory. Returns nil config if the file doesn't exist, or an error if parsing fails.

func (*Config) HasTemplateOrigin

func (c *Config) HasTemplateOrigin() bool

HasTemplateOrigin reports whether the config references a template from the library.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks the configuration for errors before execution. Returns the first validation error encountered (fail-fast).

type CreateConfigOptions

type CreateConfigOptions struct {
	TagPath    string
	SharedPath string
	BundlePath string
}

CreateConfigOptions holds the parameters for creating a config file, decoupled from the CLI framework.

type Env

type Env struct {
	Path       string `json:"TAG_PATH"`
	SharedPath string `json:"TAG_SHARED_PATH"`
	BundlePath string `json:"TAG_BUNDLE_PATH"`
}

type GlobalConfig

type GlobalConfig struct {
	Editor string `json:"editor,omitempty"`
}

GlobalConfig holds user-level TAG settings persisted across projects.

func LoadGlobalConfig

func LoadGlobalConfig() (*GlobalConfig, error)

LoadGlobalConfig loads the user-level config from $XDG_CONFIG_HOME/tag/config.json. Returns a zero-value GlobalConfig if the file does not exist.

type Hooks

type Hooks struct {
	Pre  [][]string `json:"pre"`
	Post [][]string `json:"post"`
}

type TemplateOrigin

type TemplateOrigin struct {
	Source  string `json:"source"`            // Original ref (e.g., "gh:acme/nextjs-starter")
	Name    string `json:"name"`              // Library name (e.g., "nextjs-starter")
	Version string `json:"version,omitempty"` // From tag.template.json at scaffold time
}

TemplateOrigin records which template was used to scaffold a project.

type ValidationError

type ValidationError struct {
	Field   string
	Message string
}

ValidationError represents a configuration validation failure.

func (*ValidationError) Error

func (e *ValidationError) Error() string

Jump to

Keyboard shortcuts

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