config

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2014 License: MIT Imports: 8 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"
	// Host is the default hostname for fetching problems and submitting exercises.
	// TODO: We need to operate against two hosts (one for problems and one for submissions),
	// or define a proxy that both APIs can go through.
	Host = "http://exercism.io"

	// DirExercises is the default name of the directory for active users.
	DirExercises = "exercism"
)

Variables

This section is empty.

Functions

func DefaultAssignmentPath

func DefaultAssignmentPath() string

DefaultAssignmentPath returns the absolute path of the default exercism directory

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()

func HomeDir

func HomeDir() string

HomeDir returns the user's canonical home directory. FIXME: This one will go away. Refactoring in progress.

func ReplaceTilde

func ReplaceTilde(path string) string

ReplaceTilde replaces the short-hand home path with the absolute path.

func WithDefaultPath

func WithDefaultPath(p string) string

WithDefaultPath returns the default configuration path if none is provided.

Types

type Config

type Config struct {
	APIKey   string `json:"apiKey"`
	Dir      string `json:"exercismDirectory"`
	Hostname string `json:"hostname"`
	// 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 Decode

func Decode(r io.Reader) (*Config, error)

Decode loads a Config from JSON format.

func Demo

func Demo() *Config

Demo is a default configuration for unauthenticated users.

func New

func New(key, host, dir 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)

func (*Config) Encode

func (c *Config) Encode(w io.Writer) error

Encode writes a Config into JSON format.

func (*Config) File

func (c *Config) File() string

func (*Config) SavePath

func (c *Config) SavePath(file string)

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

func (*Config) Write

func (c *Config) Write() error

Jump to

Keyboard shortcuts

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