config

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2015 License: BSD-3-Clause Imports: 9 Imported by: 1

Documentation

Overview

Package config takes care of the configuration file parsing.

Index

Constants

View Source
const (
	ConfigFolder     = "srctool"      // Configuration folder name
	DataFolder       = "srctool"      // Data folder name
	ParsersFolder    = "parsers"      // Parsers folder name
	ConfigFileName   = "srctool.conf" // Configuration file name
	ChecksumFileName = "MD5SUM"       // Checksum file name

	// DefaultConfigDir is the default configuration directoy when
	// $XDG_CONFIG_HOME is not set.
	DefaultConfigDir = ".config"

	// DefaultDataDir is the default data directoy when $XDG_DATA_HOME
	// is not set.
	DefaultDataDir = ".local/share"
)

Configuration constants

Variables

This section is empty.

Functions

func ConfigDir

func ConfigDir() string

ConfigDir returns the configuration directory of srctool.

func ConfigFilePath

func ConfigFilePath() string

ConfigFilePath returns the path of the configuration file.

func DataDir

func DataDir() string

DataDir returns the data directory of srctool.

func LocalChecksumPath

func LocalChecksumPath(parserName string) string

LocalChecksumPath returns the path of the checksum file for a given parser.

func ParserPath

func ParserPath(parserName string) string

ParserPath return the local path of a parser.

func ParserURI

func ParserURI(serverURL, parserName string) string

ParserURI returns the full URI of a parser on the download server.

func ParsersDir

func ParsersDir() string

ParsersDir returns the path of the parsers directory.

func RemoteChecksumsPath

func RemoteChecksumsPath(serverURL string) string

RemoteChecksumsPath returns the path of the remotes checksums file.

func RemoteParserPath

func RemoteParserPath(parserName string) string

RemoteParserPath returns the remote parser path.

func TempPath

func TempPath(parserName string) string

TempPath returns the temporary path of the compressed parser.

Types

type Config

type Config struct {
	DownloadServerURL string `json:"download_server_url"`
}

Config holds the configuration of srctool.

func New

func New() (*Config, error)

New creates a new Config initialized with the values defined in the configuration file located in $XDG_CONFIG_HOME/srctool/srctool.conf. If $XDG_CONFIG_HOME is not set, it uses the directory "$HOME/.config/" as config home. If some files or directories do not already exist, it creates them automatically.

func (Config) Save

func (c Config) Save() error

Save saves the Config on the disk.

Jump to

Keyboard shortcuts

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