Documentation
¶
Overview ¶
Package config provides a way to load the configuration from a file. It also comes with a default configuration that can be used if no file is found.
See individual types for more information on the configuration.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Defaults = map[string]any{ "cache.ttl_in_hours": 1, "cache.path": path.Join(StateDir(), "cache.json"), "endpoint.all": true, "endpoint.max_retry": 10, "endpoint.max_page": 5, "endpoint.per_page": 100, "view.height": 40, "view.log_path": path.Join(StateDir(), "debug.log"), "rules": []Rule{}, "keymap.normal.cursor up": []string{"up", "k"}, "keymap.normal.cursor down": []string{"down", "j"}, "keymap.normal.next page": []string{"right", "l"}, "keymap.normal.previous page": []string{"left", "h"}, "keymap.normal.go to start": []string{"home", "g"}, "keymap.normal.go to end": []string{"end", "G"}, "keymap.normal.toggle selected": []string{" "}, "keymap.normal.select all": []string{"a"}, "keymap.normal.select none": []string{"A"}, "keymap.normal.open in browser": []string{"o"}, "keymap.normal.filter mode": []string{"/"}, "keymap.normal.command mode": []string{":"}, "keymap.normal.toggle help": []string{"?"}, "keymap.normal.quit": []string{"q", "esc"}, "keymap.normal.force quit": []string{"ctrl+c"}, "keymap.filter.filter accept": []string{"enter"}, "keymap.filter.filter cancel": []string{"esc"}, "keymap.command.command accept": []string{"enter"}, "keymap.command.command cancel": []string{"esc"}, }
Functions ¶
func Dir ¶ added in v0.6.0
func Dir() string
Dir returns the directory where the configuration files are stored.
func ExpandPathWithoutTilde ¶ added in v0.6.3
Types ¶
type Cache ¶
type Cache struct {
// The path to the cache file.
Path string `mapstructure:"path"`
// The time-to-live of the cache in hours.
TTLInHours int `mapstructure:"ttl_in_hours"`
}
Cache is the configuration for the cache file.
type Data ¶ added in v0.2.2
type Data struct {
Cache Cache `mapstructure:"cache"`
Endpoint gh.Endpoint `mapstructure:"endpoint"`
Keymap Keymap `mapstructure:"keymap"`
View View `mapstructure:"view"`
Rules []Rule `mapstructure:"rules"`
}
Data holds the configuration data.
type KeyBinding ¶ added in v0.1.3
type KeyBinding []string
func (KeyBinding) Help ¶ added in v0.1.3
func (k KeyBinding) Help() string
type KeyBindings ¶ added in v0.1.3
type KeyBindings map[string]KeyBinding
type Keymap ¶ added in v0.1.3
type Keymap map[string]KeyBindings
type Rule ¶
type Rule struct {
Name string `mapstructure:"name"`
// Filters is a list of jq filters to filter the notifications.
// The filters are applied in order, like they are joined by 'and'.
// Having 'or' can be done via '(cond1) or (cond2) or ...'.
//
// E.g.:
// filters: ["A", "B or C"]
// Will filter `A and (B or C)`.
Filters []string `mapstructure:"filters"`
// Action is the action to take on the filtered notifications.
// See github.com/nobe4/internal/actions for list of available actions.
Action string `mapstructure:"action"`
// Args is the arguments to pass to the Action.
Args []string `mapstructure:"args"`
}
Rule is a struct to filter and act on notifications.
rules:
- name: showcasing conditionals
action: debug
filters:
- .author.login == "dependabot[bot]"
- >
(.subject.title | contains("something unimportant")) or
(.subject.title | contains("something already done"))
- name: ignore ci failures for the current repo
action: done
filters:
- .repository.full_name == "nobe4/gh-not"
- .reason == "ci_activity"
func (Rule) Filter ¶ added in v0.3.5
func (r Rule) Filter(n notifications.Notifications) (notifications.Notifications, error)
Filter filters the notifications with the jq filters and returns the IDs.
Click to show internal directories.
Click to hide internal directories.