config

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2015 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// File is the default name of the JSON file where the config written.
	// The user can pass an alternate filename when using the CLI.
	File = ".exercism.json"
	// LegacyFile is the name of the original config file.
	// It is a misnomer, since the config was in json, not go.
	LegacyFile = ".exercism.go"

	// DirExercises is the default name of the directory for active users.
	// Make this non-exported when handlers.Login is deleted.
	DirExercises = "exercism"
)

Variables

This section is empty.

Functions

func FilePath

func FilePath(file string) (string, error)

FilePath returns the path to the config file.

func Home

func Home() (string, error)

Home returns the user's canonical home directory. See: http://stackoverflow.com/questions/7922270/obtain-users-home-directory we can't cross compile using cgo and use user.Current()

Types

type Config

type Config struct {
	APIKey string `json:"apiKey"`
	Dir    string `json:"dir"`
	API    string `json:"api"`
	XAPI   string `json:"xapi"`

	// deprecated, get rid of them when nobody uses 1.7.0 anymore
	ExercismDirectory string `json:"exercismDirectory,omitempty"`
	Hostname          string `json:"hostname,omitempty"`
	ProblemsHost      string `json:"problemsHost,omitempty"`
	// contains filtered or unexported fields
}

Config represents the settings for particular user. This defines both the auth for talking to the API, as well as where to put problems that get downloaded.

func New

func New(key, host, dir, xapi string) (*Config, error)

New returns a new config. It will attempt to set defaults where no value is passed in.

func Read

func Read(file string) (*Config, error)

Read loads the config from the stored JSON file.

func (*Config) File

func (c *Config) File() string

File represents the path to the config file.

func (*Config) IsAuthenticated added in v1.7.1

func (c *Config) IsAuthenticated() bool

IsAuthenticated returns true if the config contains an API key. This does not check whether or not that key is valid.

func (*Config) Read added in v1.7.1

func (c *Config) Read(file string) error

Read loads the config from the stored JSON file.

func (*Config) SavePath

func (c *Config) SavePath(file string)

SavePath allows the user to customize the location of the JSON file.

func (*Config) Update added in v1.7.2

func (c *Config) Update(key, host, dir, xapi string)

Update sets new values where given.

func (*Config) Write

func (c *Config) Write() error

Write() saves the config as JSON.

Jump to

Keyboard shortcuts

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