config

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultConfigFileName is the name of the config file in the user's home directory
	DefaultConfigFileName = ".github-notifier.conf"

	// DefaultStateFileName is the name of the state file in the user's home directory.
	// It lives alongside the config file and holds the persisted seen/tracked PR state.
	DefaultStateFileName = ".github-notifier.state.json"
)
View Source
const DefaultIgnoreFileName = "ignore.yaml"

Variables

This section is empty.

Functions

func CreateDefaultIgnoreFile

func CreateDefaultIgnoreFile(path string) error

CreateDefaultIgnoreFile writes a self-documenting ignore.yaml if it does not exist.

func DefaultIgnoreFilePath

func DefaultIgnoreFilePath(configFilePath string) string

DefaultIgnoreFilePath returns the default path for ignore.yaml, next to the config file.

func LoadIgnoreConfig

func LoadIgnoreConfig(path string) (*pullrequest.IgnoreConfig, error)

LoadIgnoreConfig loads ignore.yaml from the given path. Returns nil without error if the file does not exist. Returns nil with an error if the file exists but cannot be parsed.

func OpenInEditor

func OpenInEditor(path string) error

OpenInEditor opens the config file in the user's default text editor. It uses platform-specific commands: xdg-open (Linux), open -t (macOS), notepad (Windows).

func OpenOrCreateIgnoreFile

func OpenOrCreateIgnoreFile(path string) error

OpenOrCreateIgnoreFile opens ignore.yaml in the user's editor, creating it if missing.

func WatchForValidConfig

func WatchForValidConfig(ctx context.Context, path string) <-chan *Config

WatchForValidConfig watches the config file at path for changes. When a valid config (with a non-empty GitHub token) is detected, it sends the config on the returned channel and stops watching. The caller should cancel the context to stop watching early.

func WatchForValidIgnoreConfig

func WatchForValidIgnoreConfig(ctx context.Context, ignoreFilePath string) <-chan *pullrequest.IgnoreConfig

WatchForValidIgnoreConfig watches ignoreFilePath and sends a freshly parsed *pullrequest.IgnoreConfig whenever the file changes and parses successfully. The channel is closed when ctx is cancelled.

Types

type Config

type Config struct {
	GitHubToken             string
	SlackOAuthToken         string
	CheckInterval           int // in minutes
	MaxNumberOfRepos        int
	MaxNumberOfPRs          int
	EnableActivityTracking  bool   // Enable checking for comments/reviews/commits (increases API usage)
	RecentPRThresholdHours  int    // PRs created within this are "recent" and checked every minute
	StalePRCheckIntervalMin int    // Check stale PRs every N minutes
	IncludeDraftPRs         bool   // Include draft PRs where user participated (default: true)
	MacOSNotificationSender string // macOS notification sender bundle ID (optional)

	// ConfigFilePath stores the resolved config file path (not a user setting)
	ConfigFilePath string
}

Config holds application configuration

func LoadConfig

func LoadConfig() *Config

LoadConfig loads configuration with the following priority:

  1. Environment variables (highest priority)
  2. Config file (~/.github-notifier.conf)
  3. Default values (lowest priority)

If the config file does not exist, it is created with commented-out defaults.

func LoadConfigWithPath

func LoadConfigWithPath(path string) *Config

LoadConfigWithPath loads configuration using a specific config file path. If path is empty, it defaults to ~/.github-notifier.conf.

func (*Config) IsValid

func (c *Config) IsValid() bool

IsValid checks if the configuration is valid

func (*Config) StateFilePath

func (c *Config) StateFilePath() string

StateFilePath returns the path to the JSON state file that persists seen and tracked PR state across process restarts. It is a sibling of ConfigFilePath with the name DefaultStateFileName.

Jump to

Keyboard shortcuts

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