config

package
v3.0.10+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2018 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// DefaultDirName is the default name used for config and workspace directories.
	DefaultDirName string
)

Functions

func DefaultWorkspaceDir

func DefaultWorkspaceDir(cfg Config) 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

func InferSiteURL(apiURL string) string

InferSiteURL guesses what the website URL is. The basis for the guess is which API we're submitting to.

func Resolve

func Resolve(path, home string) string

Resolve cleans up filesystem paths.

func SetDefaultDirName

func SetDefaultDirName(binaryName string)

SetDefaultDirName configures the default directory name based on the name of the binary.

func SettingsURL

func SettingsURL(apiURL string) string

SettingsURL provides a link to where the user can find their API token.

Types

type Config

type Config struct {
	OS              string
	Home            string
	Dir             string
	DefaultBaseURL  string
	DefaultDirName  string
	UserViperConfig *viper.Viper
	Persister       Persister
}

Config lets us inject configuration options into commands.

func NewConfig

func NewConfig() Config

NewConfig provides a configuration with default values.

func (Config) Save

func (c Config) 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.

func (FilePersister) Save

func (p FilePersister) Save(v *viper.Viper, basename string) error

Save writes the viper config to the target location on the filesystem.

type InMemoryPersister

type InMemoryPersister struct{}

InMemoryPersister is a noop persister for use in unit tests.

func (InMemoryPersister) Save

Save does nothing.

type Persister

type Persister interface {
	Save(*viper.Viper, string) error
}

Persister saves viper configs.

Jump to

Keyboard shortcuts

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