Documentation
¶
Index ¶
- func CentralProjectDir(projectName string) (string, error)
- func CentralStoreRoot() (string, error)
- func ConfigPath() (string, error)
- func DetectProjectPath(cwd string) string
- func IsConfigured() bool
- func ResolveName(cfg Config, cwd string, explicit string) (name string, source string)
- func Save(cfg Config) error
- func SharedConfigPath() (string, error)
- type Config
- type ProjectConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CentralProjectDir ¶
CentralProjectDir returns <centralRoot>/tickets/<projectName>.
func CentralStoreRoot ¶
CentralStoreRoot returns the central ticket store root directory. Returns an error if central_root is not configured — run `tk init` first.
func DetectProjectPath ¶
DetectProjectPath returns git top-level directory if available; otherwise cwd.
func IsConfigured ¶
func IsConfigured() bool
IsConfigured returns true if ~/.ticket/config.yaml exists and has central_root set.
func ResolveName ¶
ResolveName resolves project name with precedence: 1) explicit override 2) config path mapping 3) git remote name 4) directory name
Names are sanitized to prevent path traversal (no ".." or path separators).
func Save ¶
Save writes the config to both local and shared files, splitting fields appropriately. Local gets top-level fields + per-project path. Shared gets per-project store, auto_link, auto_close, registered_at.
func SharedConfigPath ¶
SharedConfigPath returns <central_root>/config.yaml.
Types ¶
type Config ¶
type Config struct {
CentralRoot string `yaml:"central_root,omitempty" json:"central_root,omitempty"`
GitEmail string `yaml:"git_email,omitempty" json:"git_email,omitempty"`
GitName string `yaml:"git_name,omitempty" json:"git_name,omitempty"`
DefaultStore string `yaml:"default_store,omitempty" json:"default_store,omitempty"`
SyncInterval string `yaml:"sync_interval,omitempty" json:"sync_interval,omitempty"`
Projects map[string]ProjectConfig `yaml:"projects"`
}
Config stores tk project configuration (merged view of local + shared).
func Load ¶
Load reads both local (~/.ticket/config.yaml) and shared (<central_root>/config.yaml) configs, merging them into a single Config. Local fields (central_root, git_email, git_name, default_store, sync_interval, per-project path) come from local config. Shared fields (per-project store, auto_link, auto_close, registered_at) come from shared config. Missing files are not errors — returns what's available.
func (*Config) UpsertProject ¶
func (cfg *Config) UpsertProject(name string, project ProjectConfig)
UpsertProject inserts or updates a project entry.
type ProjectConfig ¶
type ProjectConfig struct {
Path string `yaml:"path,omitempty" json:"path,omitempty"`
Store string `yaml:"store,omitempty" json:"store,omitempty"`
AutoLink bool `yaml:"auto_link" json:"auto_link"`
AutoClose bool `yaml:"auto_close" json:"auto_close"`
RegisteredAt string `yaml:"registered_at,omitempty" json:"registered_at,omitempty"`
}
ProjectConfig stores per-project settings.