config

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FiltersConfigPath added in v1.6.0

func FiltersConfigPath() string

FiltersConfigPath returns the path to the custom filters file.

func LoadCustomFilters added in v1.6.0

func LoadCustomFilters() map[string]CustomFilter

LoadCustomFilters reads the custom filters config file. Returns an empty map if the file doesn't exist or can't be parsed.

func LoadCustomFiltersFrom added in v1.6.0

func LoadCustomFiltersFrom(path string) map[string]CustomFilter

LoadCustomFiltersFrom reads custom filters from a specific path.

func LoadCustomFiltersWithLocal added in v1.6.0

func LoadCustomFiltersWithLocal(cwd string) map[string]CustomFilter

LoadCustomFiltersWithLocal loads global custom filters, then overlays a local .chop-filters.yml from the given directory (if it exists). Local filters are merged on top of global ones (local wins on conflict).

func ParseCustomFilters added in v1.6.0

func ParseCustomFilters(data []byte) map[string]CustomFilter

ParseCustomFilters parses YAML bytes into a custom filters map.

func Path

func Path() string

Path returns the config file path, respecting XDG_CONFIG_HOME.

Types

type Config

type Config struct {
	Disabled []string
}

Config holds user preferences loaded from ~/.config/chop/config.yml.

func Load

func Load() Config

Load reads the config file and returns a Config. Returns defaults if the file doesn't exist or can't be parsed.

func LoadFrom

func LoadFrom(path string) Config

LoadFrom reads config from a specific path. Exported for testing.

func LoadWithLocal added in v1.1.0

func LoadWithLocal(cwd string) Config

LoadWithLocal loads the global config, then overlays a local .chop.yml from the given directory (if it exists). The local disabled list fully replaces the global one.

func (Config) IsDisabled

func (c Config) IsDisabled(command string, args ...string) bool

IsDisabled returns true if the given base command (and optional subcommand) matches an entry in the disabled list.

Matching rules:

  • "git" disables all git subcommands
  • "git diff" disables only "git diff"

Call with: IsDisabled("git", "diff") or IsDisabled("git")

type CustomFilter added in v1.6.0

type CustomFilter struct {
	Keep []string `yaml:"keep"` // regex patterns - only lines matching at least one are kept
	Drop []string `yaml:"drop"` // regex patterns - lines matching any are removed
	Head int      `yaml:"head"` // keep only first N lines (applied after keep/drop)
	Tail int      `yaml:"tail"` // keep only last N lines (applied after keep/drop)
	Exec string   `yaml:"exec"` // external script: pipe output through this command
}

CustomFilter defines a user-configured output filter for a specific command.

func LookupCustomFilter added in v1.6.0

func LookupCustomFilter(filters map[string]CustomFilter, command string, args []string) *CustomFilter

LookupCustomFilter finds a custom filter for the given command and args. It checks "command subcommand" first, then falls back to "command".

type CustomFiltersConfig added in v1.6.0

type CustomFiltersConfig struct {
	Filters map[string]CustomFilter `yaml:"filters"`
}

CustomFiltersConfig holds the full filters.yml content.

Jump to

Keyboard shortcuts

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