config

package
v0.8.2-alpha Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2018 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package config handles config files, -config, and env vars at startup.

Index

Constants

View Source
const (
	DEFAULT_CONFIG_FILES = "/etc/spinc/spinc.yaml,~/.spinc.yaml"
	DEFAULT_TIMEOUT      = 10000 // 10s
)

Variables

View Source
var (
	ErrUnknownRequest = errors.New("request does not exist")
)

Functions

func Help

func Help(full bool, rmc rm.Client)

Help prints full help or minimal request help if full is false. An rm.Client is used to get the list of available requests from the Request Manager API.

func RequestHelp

func RequestHelp(reqName string, rmc rm.Client) error

Types

type Command

type Command struct {
	Cmd  string   `arg:"positional"`
	Args []string `arg:"positional"`
}

Command represents a command (start, stop, etc.) and its values.

type CommandLine

type CommandLine struct {
	Options
	Command
}

CommandLine represents options (--addr, etc.) and commands (start, etc.). The caller is expected to copy and use the embedded structs separately, like:

var o config.Options = cmdLine.Options
var c config.Command = cmdLine.Command

Some commands and options are mutually exclusive, like --ping and --version. Others can be used together, like --addr and --timeout with any command.

func ParseCommandLine

func ParseCommandLine(def Options) CommandLine

ParseCommandLine parses the command line and env vars. Command line options override env vars. Default options are used unless overridden by env vars or command line options. Defaults are usually parsed from config files.

type Options

type Options struct {
	Addr    string `arg:"env" yaml:"addr"`
	Config  string `arg:"env"`
	Debug   bool
	Env     string
	Help    bool
	Ping    bool
	Timeout uint `arg:"env" yaml:"timeout"`
	Version bool
	Verbose bool `arg:"-v"`
}

Options represents typical command line options: --addr, --config, etc.

func ParseConfigFiles

func ParseConfigFiles(files string, debug bool) Options

Jump to

Keyboard shortcuts

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