Documentation
¶
Index ¶
- Constants
- Variables
- func OptionNames() []string
- func SaveConfig(w io.Writer, config *Config) error
- func ValidateArchitecture(arch string) error
- func ValidateContext(ctx Context) error
- func ValidateDist(os, arch string) error
- func ValidateFile(file string) error
- func ValidateLogLevel(level string) error
- func ValidateOS(os string) error
- func ValidateOwner(owner string) error
- func ValidateRegexp(pattern string) error
- func ValidateRoot(root string) error
- type BoolOption
- type Config
- func (c *Config) Architecture() string
- func (c *Config) ExtractExclude() string
- func (c *Config) ExtractInclude() string
- func (c *Config) ExtractModes() FileModes
- func (c *Config) GitHubHost() string
- func (c *Config) GitHubToken() string
- func (c *Config) GitHubUser() string
- func (c *Config) HistoryFile() string
- func (c *Config) HistorySave() bool
- func (c *Config) LogDate() bool
- func (c *Config) LogFlags() int
- func (c *Config) LogLevel() string
- func (c *Config) LogLongFile() bool
- func (c *Config) LogMicroSeconds() bool
- func (c *Config) LogShortFile() bool
- func (c *Config) LogTime() bool
- func (c *Config) LogUTC() bool
- func (c *Config) OS() string
- func (c *Config) Root() string
- func (c *Config) Stderr() io.Writer
- func (c *Config) Stdin() io.Reader
- func (c *Config) Stdout() io.Writer
- type Context
- type ExtractConfig
- type ExtractContext
- type FileMode
- type FileModes
- type GitHubConfig
- type GitHubContext
- type HistoryConfig
- type HistoryContext
- type IOContext
- type LogConfig
- type LogContext
- type MockContext
- func (c *MockContext) Architecture() string
- func (c *MockContext) ExtractExclude() string
- func (c *MockContext) ExtractInclude() string
- func (c *MockContext) ExtractModes() FileModes
- func (c *MockContext) GitHubHost() string
- func (c *MockContext) GitHubToken() string
- func (c *MockContext) GitHubUser() string
- func (c *MockContext) HistoryFile() string
- func (c *MockContext) HistorySave() bool
- func (c *MockContext) LogDate() bool
- func (c *MockContext) LogFlags() int
- func (c *MockContext) LogLevel() string
- func (c *MockContext) LogLongFile() bool
- func (c *MockContext) LogMicroSeconds() bool
- func (c *MockContext) LogShortFile() bool
- func (c *MockContext) LogTime() bool
- func (c *MockContext) LogUTC() bool
- func (c *MockContext) OS() string
- func (c *MockContext) Root() string
- func (c *MockContext) Stderr() io.Writer
- func (c *MockContext) Stdin() io.Reader
- func (c *MockContext) Stdout() io.Writer
- type OptionAccessor
Constants ¶
View Source
const ( // DefaultLogLevel is the default level to output log DefaultLogLevel = "warn" // DefaultGitHubHost is the default host of the GitHub DefaultGitHubHost = "github.com" )
View Source
const FileModeSeparator = '|'
Variables ¶
View Source
var ( ErrEmptyValue = errors.New("empty value") ErrInvalidOptionName = errors.New("invalid option name") )
View Source
var ( TrueOption = BoolOption("yes") FalseOption = BoolOption("no") EmptyBoolOption = BoolOption("") )
View Source
var ( // DefaultHistoryFile is the default file to save history DefaultHistoryFile = filepath.Join(xdg.CacheHome(), "gordon", "history") )
Functions ¶
func OptionNames ¶
func OptionNames() []string
func ValidateArchitecture ¶
func ValidateContext ¶
func ValidateDist ¶
func ValidateFile ¶
func ValidateLogLevel ¶
func ValidateOS ¶
func ValidateOwner ¶
func ValidateRegexp ¶
func ValidateRoot ¶
Types ¶
type BoolOption ¶
type BoolOption string
func (BoolOption) Bool ¶
func (c BoolOption) Bool() bool
func (*BoolOption) Decode ¶
func (c *BoolOption) Decode(repl string) error
Decode implements the interface `envdecode.Decoder`
func (BoolOption) MarshalText ¶
func (c BoolOption) MarshalText() ([]byte, error)
MarshalText implements the interface `encoding.TextMarshaler`
func (*BoolOption) SetBool ¶
func (c *BoolOption) SetBool(b bool)
func (BoolOption) String ¶
func (c BoolOption) String() string
func (*BoolOption) UnmarshalText ¶
func (c *BoolOption) UnmarshalText(raw []byte) error
UnmarshalText implements the interface `encoding.TextUnmarshaler`
type Config ¶
type Config struct { context.Context `yaml:"-"` Log LogConfig `yaml:"log,omitempty"` GitHub GitHubConfig `yaml:"github,omitempty"` History HistoryConfig `yaml:"history,omitempty"` Extract ExtractConfig `yaml:"extract,omitempty"` VRoot string `yaml:"root,omitempty" env:"GORDON_ROOT"` VArchitecture string `yaml:"architecture,omitempty" env:"GORDON_ARCHITECTURE"` VOS string `yaml:"os,omitempty" env:"GORDON_OS"` }
Config holds configuration file values.
func DefaultConfig ¶
func DefaultConfig() *Config
func GetEnvarConfig ¶
func LoadKeyring ¶
func LoadKeyring() *Config
func MergeConfig ¶
func (*Config) Architecture ¶
func (*Config) ExtractExclude ¶
func (*Config) ExtractInclude ¶
func (*Config) ExtractModes ¶
func (*Config) GitHubHost ¶
func (*Config) GitHubToken ¶
func (*Config) GitHubUser ¶
func (*Config) HistoryFile ¶
func (*Config) HistorySave ¶
func (*Config) LogLongFile ¶
func (*Config) LogMicroSeconds ¶
func (*Config) LogShortFile ¶
type Context ¶
type Context interface { context.Context IOContext LogContext GitHubContext HistoryContext ExtractContext Root() string Architecture() string OS() string }
Context holds configurations and environments
type ExtractConfig ¶
type ExtractContext ¶
type FileModes ¶
type FileModes []FileMode
func (FileModes) MarshalText ¶
func (*FileModes) UnmarshalText ¶
type GitHubConfig ¶
type GitHubContext ¶
type HistoryConfig ¶
type HistoryConfig struct { File string `yaml:"file,omitempty" env:"GORDON_HISTORY_FILE"` Save BoolOption `yaml:"save" env:"GORDON_HISTORY_SAVE"` }
type HistoryContext ¶
type LogConfig ¶
type LogConfig struct { Level string `yaml:"level,omitempty" env:"GORDON_LOG_LEVEL"` Date BoolOption `yaml:"date" env:"GORDON_LOG_DATE"` // the date in the local time zone: 2009/01/23 Time BoolOption `yaml:"time" env:"GORDON_LOG_TIME"` // the time in the local time zone: 01:23:23 MicroSeconds BoolOption `yaml:"microseconds" env:"GORDON_LOG_MICROSECONDS"` // microsecond resolution: 01:23:23.123123. assumes Ltime. LongFile BoolOption `yaml:"longfile" env:"GORDON_LOG_LONGFILE"` // full file name and line number: /a/b/c/d.go:23 ShortFile BoolOption `yaml:"shortfile" env:"GORDON_LOG_SHORTFILE"` // final file name element and line number: d.go:23. overrides Llongfile UTC BoolOption `yaml:"utc" env:"GORDON_LOG_UTC"` // if Ldate or Ltime is set, use UTC rather than the local time zone }
type LogContext ¶
type MockContext ¶
type MockContext struct { context.Context MStdin io.Reader MStdout io.Writer MStderr io.Writer MLogLevel string MLogFlags int MLogDate bool MLogTime bool MLogMicroSeconds bool MLogLongFile bool MLogShortFile bool MLogUTC bool MGitHubUser string MGitHubToken string MGitHubHost string MHistoryFile string MHistorySave bool MExtractModes FileModes MExtractExclude string MExtractInclude string MRoot string MArchitecture string MOS string }
func (*MockContext) Architecture ¶
func (c *MockContext) Architecture() string
func (*MockContext) ExtractExclude ¶
func (c *MockContext) ExtractExclude() string
func (*MockContext) ExtractInclude ¶
func (c *MockContext) ExtractInclude() string
func (*MockContext) ExtractModes ¶
func (c *MockContext) ExtractModes() FileModes
func (*MockContext) GitHubHost ¶
func (c *MockContext) GitHubHost() string
func (*MockContext) GitHubToken ¶
func (c *MockContext) GitHubToken() string
func (*MockContext) GitHubUser ¶
func (c *MockContext) GitHubUser() string
func (*MockContext) HistoryFile ¶
func (c *MockContext) HistoryFile() string
func (*MockContext) HistorySave ¶
func (c *MockContext) HistorySave() bool
func (*MockContext) LogDate ¶
func (c *MockContext) LogDate() bool
func (*MockContext) LogFlags ¶
func (c *MockContext) LogFlags() int
func (*MockContext) LogLevel ¶
func (c *MockContext) LogLevel() string
func (*MockContext) LogLongFile ¶
func (c *MockContext) LogLongFile() bool
func (*MockContext) LogMicroSeconds ¶
func (c *MockContext) LogMicroSeconds() bool
func (*MockContext) LogShortFile ¶
func (c *MockContext) LogShortFile() bool
func (*MockContext) LogTime ¶
func (c *MockContext) LogTime() bool
func (*MockContext) LogUTC ¶
func (c *MockContext) LogUTC() bool
func (*MockContext) OS ¶
func (c *MockContext) OS() string
func (*MockContext) Root ¶
func (c *MockContext) Root() string
func (*MockContext) Stderr ¶
func (c *MockContext) Stderr() io.Writer
func (*MockContext) Stdin ¶
func (c *MockContext) Stdin() io.Reader
func (*MockContext) Stdout ¶
func (c *MockContext) Stdout() io.Writer
type OptionAccessor ¶
type OptionAccessor struct {
// contains filtered or unexported fields
}
func Option ¶
func Option(optionName string) (*OptionAccessor, error)
func Options ¶
func Options() []OptionAccessor
func (OptionAccessor) Get ¶
func (a OptionAccessor) Get(cfg *Config) string
func (OptionAccessor) Prompt ¶
func (a OptionAccessor) Prompt(cfg *Config) error
func (OptionAccessor) Unset ¶
func (a OptionAccessor) Unset(cfg *Config) error
Click to show internal directories.
Click to hide internal directories.