config

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package config provides configuration management for GitHubby

Index

Constants

View Source
const (
	// DefaultConfigFileName is the name of the config file (without extension)
	DefaultConfigFileName = ".githubby"
	// DefaultConfigFileType is the config file extension
	DefaultConfigFileType = "yaml"
)

Variables

This section is empty.

Functions

func EnsureConfigFile

func EnsureConfigFile() error

EnsureConfigFile creates the config file with defaults if it doesn't exist

func GetConfigFilePath

func GetConfigFilePath() (string, error)

GetConfigFilePath returns the path to the config file

Types

type Config

type Config struct {
	// Global flags
	Verbose bool   `yaml:"verbose"`
	DryRun  bool   `yaml:"dry-run"`
	Token   string `yaml:"token"`

	// Clean command
	Repository  string `yaml:"repository"`
	FilterDays  int    `yaml:"filter-days"`
	FilterCount int    `yaml:"filter-count"`

	// Sync command
	User           string   `yaml:"user"`
	Org            string   `yaml:"org"`
	Target         string   `yaml:"target"`
	IncludePrivate bool     `yaml:"include-private"`
	Include        []string `yaml:"include"`
	Exclude        []string `yaml:"exclude"`
}

Config holds all application configuration

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a new Config with default values

func Load

func Load() (*Config, error)

Load loads configuration from the default config file

func LoadFrom

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

LoadFrom loads configuration from a file

func (*Config) Clone

func (c *Config) Clone() *Config

Clone returns a deep copy of the config

func (*Config) SaveTo

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

SaveTo saves configuration to a file with secure permissions

type Loader

type Loader struct {
	// contains filtered or unexported fields
}

Loader manages configuration loading from multiple sources

func NewLoader

func NewLoader() *Loader

NewLoader creates a new configuration loader

func (*Loader) BindFlag

func (l *Loader) BindFlag(key string, flag *pflag.Flag) error

BindFlag binds a flag to a viper key

func (*Loader) GetBool

func (l *Loader) GetBool(key string) bool

GetBool returns a bool value

func (*Loader) GetInt

func (l *Loader) GetInt(key string) int

GetInt returns an int value

func (*Loader) GetString

func (l *Loader) GetString(key string) string

GetString returns a string value

func (*Loader) Initialize

func (l *Loader) Initialize() error

Initialize sets up the configuration loader

func (*Loader) InjectToCommand

func (l *Loader) InjectToCommand(cmd *cobra.Command)

InjectToCommand injects viper config values into command flags that weren't explicitly set via command line

func (*Loader) IsSet

func (l *Loader) IsSet(key string) bool

IsSet checks if a key has been set

func (*Loader) SetDefault

func (l *Loader) SetDefault(key string, value interface{})

SetDefault sets a default value for a key

func (*Loader) Viper

func (l *Loader) Viper() *viper.Viper

Viper returns the underlying viper instance

Jump to

Keyboard shortcuts

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