Documentation ¶
Index ¶
- Variables
- func DefaultWorkspaceDir(cfg Configuration) string
- func Dir() string
- func InferSiteURL(apiURL string) string
- func Resolve(path, home string) string
- func SetDefaultDirName(binaryName string)
- func Write(f filer) error
- type CLIConfig
- type Config
- type Configuration
- type FilePersister
- type InMemoryPersister
- type Persister
- type Track
- type Tracks
- type UserConfig
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultDirName is the default name used for config and workspace directories. DefaultDirName string )
Functions ¶
func DefaultWorkspaceDir ¶
func DefaultWorkspaceDir(cfg Configuration) string
DefaultWorkspaceDir provides a sensible default for the Exercism workspace. The default is different depending on the platform, in order to best match the conventions for that platform. It places the directory in the user's home path.
func Dir ¶
func Dir() string
Dir is the configured config home directory. All the cli-related config files live in this directory.
func InferSiteURL ¶
InferSiteURL guesses what the website URL is. The basis for the guess is which API we're submitting to.
func SetDefaultDirName ¶
func SetDefaultDirName(binaryName string)
SetDefaultDirName configures the default directory name based on the name of the binary.
Types ¶
type CLIConfig ¶
CLIConfig contains settings specific to the behavior of the CLI.
func NewCLIConfig ¶
NewCLIConfig loads the config file in the config directory.
func NewEmptyCLIConfig ¶
func NewEmptyCLIConfig() *CLIConfig
NewEmptyCLIConfig doesn't load the config from file or set default values.
func (*CLIConfig) SetDefaults ¶
func (cfg *CLIConfig) SetDefaults()
SetDefaults ensures that we have all the necessary settings for the CLI.
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config is a wrapper around a viper configuration.
type Configuration ¶
type Configuration struct { OS string Home string Dir string DefaultBaseURL string DefaultDirName string UserViperConfig *viper.Viper UserConfig *UserConfig CLIConfig *CLIConfig Persister Persister }
Configuration lets us inject configuration options into commands. Note that we are slowly working towards getting rid of the config.Config, config.UserConfig, and config.CLIConfig types. Once we do, we can rename this type to Config, and get rid of the User and CLI fields.
func NewConfiguration ¶
func NewConfiguration() Configuration
NewConfiguration provides a configuration with default values.
func (Configuration) Save ¶
func (c Configuration) Save(basename string) error
Save persists a viper config of the base name.
type FilePersister ¶
type FilePersister struct {
Dir string
}
FilePersister saves viper configs to the file system.
type InMemoryPersister ¶
type InMemoryPersister struct{}
InMemoryPersister is a noop persister for use in unit tests.
type Track ¶
Track holds the CLI-related settings for a track.
func (*Track) AcceptFilename ¶
AcceptFilename judges a files admissability based on the name.
func (*Track) CompileRegexes ¶
CompileRegexes precompiles the ignore patterns.
func (*Track) SetDefaults ¶
func (t *Track) SetDefaults()
SetDefaults configures a track with default values.
type UserConfig ¶
type UserConfig struct { *Config Workspace string Token string Home string APIBaseURL string // contains filtered or unexported fields }
UserConfig contains user-specific settings.
func NewEmptyUserConfig ¶
func NewEmptyUserConfig() *UserConfig
NewEmptyUserConfig creates a user configuration without loading it.
func NewUserConfig ¶
func NewUserConfig() (*UserConfig, error)
NewUserConfig loads a user configuration if it exists.
func (*UserConfig) Load ¶
func (cfg *UserConfig) Load(v *viper.Viper) error
Load reads a viper configuration into the config.
func (*UserConfig) SetDefaults ¶
func (cfg *UserConfig) SetDefaults()
SetDefaults ensures that we have proper values where possible.