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.
Output the default configuration (free of rules) with `gh-not config --init`.
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, "view.height": 40, "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.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", "ctrl+c"}, "keymap.filter.confirm": []string{"enter"}, "keymap.filter.cancel": []string{"esc", "ctrl+c"}, "keymap.command.confirm": []string{"enter"}, "keymap.command.cancel": []string{"esc", "ctrl+c"}, }
Functions ¶
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 Endpoint `mapstructure:"endpoint"`
Keymap Keymap `mapstructure:"keymap"`
View View `mapstructure:"view"`
Rules []Rule `mapstructure:"rules"`
}
Data holds the configuration data.
type Endpoint ¶ added in v0.1.3
type Endpoint struct {
// Pull all notifications from the endpoint.
// By default, only the unread notifications are fetched.
// This maps to `?all=true|false` in the GitHub API.
// See https://docs.github.com/en/rest/activity/notifications?apiVersion=2022-11-28#list-notifications-for-the-authenticated-user
All bool `mapstructure:"all"`
// The maximum number of retries to fetch notifications.
// The Notifications API is notably flaky, retrying HTTP requests is
// definitely needed.
MaxRetry int `mapstructure:"max_retry"`
// The number of notification pages to fetch.
// This will cap the `?page=X` parameter in the GitHub API.
// See https://docs.github.com/en/rest/activity/notifications?apiVersion=2022-11-28#list-notifications-for-the-authenticated-user
MaxPage int `mapstructure:"max_page"`
}
Endpoint is the configuration for the GitHub API endpoint.
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/actors for list of available actions.
Action string `mapstructure:"action"`
}
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) FilterIds ¶ added in v0.1.0
func (r Rule) FilterIds(n notifications.Notifications) ([]string, error)
FilterIds filters the notifications with the jq filters and returns the IDs. TODO: return the notifications instead of the IDs.
Click to show internal directories.
Click to hide internal directories.