config

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigDir

func ConfigDir() string

ConfigDir returns the directory where the config file lives.

func ConfigPath

func ConfigPath() string

ConfigPath returns the full path to the config file.

func DefaultCachePath

func DefaultCachePath() string

DefaultCachePath returns the default cache directory path.

func DefaultWorkDir

func DefaultWorkDir() string

DefaultWorkDir returns the default work directory path.

func ExpandTilde

func ExpandTilde(path string) string

ExpandTilde replaces a leading ~ with the user's home directory.

Types

type Config

type Config struct {
	WorkDir   string                  `toml:"work_dir"`
	CachePath string                  `toml:"cache_path"`
	Filters   Filters                 `toml:"filters"`
	Domains   map[string]DomainConfig `toml:"domains"`
}

Config represents the work CLI configuration.

func Load

func Load() (*Config, error)

Load reads the config file from the default path.

func LoadFrom

func LoadFrom(path string) (*Config, error)

LoadFrom reads and parses a config file from the given path. If the file does not exist, returns a Config with default values.

func (*Config) CacheDir

func (c *Config) CacheDir() string

CacheDir returns the cache directory with ~ expanded to an absolute path.

func (*Config) CacheFile

func (c *Config) CacheFile() string

CacheFile returns the full path to the cache.json file.

func (*Config) DomainFavorites

func (c *Config) DomainFavorites(domain string) []string

DomainFavorites returns the favorite org names for the given domain. Returns nil if the domain is not configured or has no favorites.

func (*Config) DomainNames

func (c *Config) DomainNames() []string

DomainNames returns the configured domain hostnames.

func (*Config) GetDefaultDomain

func (c *Config) GetDefaultDomain() string

GetDefaultDomain returns the hostname of the domain marked as default, or an empty string if no domain is configured as default.

func (*Config) RepoPath

func (c *Config) RepoPath(domain, org, repo string) string

RepoPath computes the local filesystem path for a repository. Default domain repos omit the domain segment: {work_dir}/{org}/{repo} Non-default domain repos include it: {work_dir}/{domain}/{org}/{repo}

func (*Config) Save

func (c *Config) Save() error

Save writes the config to the default config path.

func (*Config) SaveTo

func (c *Config) SaveTo(path string) error

SaveTo writes the config to the given path, creating parent directories as needed. Domain keys containing dots are quoted automatically by the TOML encoder so that [domains."github.com"] stays a single map key rather than being misread as nested tables.

func (*Config) ShouldIncludeOrg

func (c *Config) ShouldIncludeOrg(org string) bool

ShouldIncludeOrg determines whether an org passes the global include/exclude filters.

func (*Config) WorkDirExpanded

func (c *Config) WorkDirExpanded() string

WorkDirExpanded returns the work directory with ~ expanded to an absolute path.

type DomainConfig

type DomainConfig struct {
	IsDefault    bool     `toml:"is_default"`
	FavoriteOrgs []string `toml:"favorite_orgs"`
}

DomainConfig holds settings for a single GitHub domain.

type Filters

type Filters struct {
	ExcludeOrgs []string `toml:"exclude_orgs"`
	IncludeOrgs []string `toml:"include_orgs"`
}

Filters controls which orgs are included or excluded during cache updates.

func (*Filters) ShouldInclude

func (f *Filters) ShouldInclude(org string) bool

ShouldInclude determines whether an org should be included based on filter rules. If include_orgs is non-empty, only orgs in that list pass. Otherwise, orgs in exclude_orgs are rejected and everything else passes.

Jump to

Keyboard shortcuts

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