v0.8.0-alpha Latest Latest

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

Go to latest
Published: Nov 28, 2017 License: Apache-2.0 Imports: 10 Imported by: 0



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



View Source
const (
	DEFAULT_CONFIG_FILES = "/etc/etre/es.yaml,~/.es.yaml"
	DEFAULT_IFS          = ","
	DEFAULT_TIMEOUT      = 5000 // 5s


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


func Help

func Help()

func ParseArgs

func ParseArgs(args []string) (string, []string, string)


type CommandLine

type CommandLine struct {
	Args []string `arg:"positional"`

CommandLine represents options (--addr, etc.) and args: entity type, return labels, and query predicates. The caller is expected to copy and use the embedded structs separately, like:

var o config.Options = cmdLine.Options
for i, arg := range cmdline.Args {

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   `arg:"env" yaml:"debug"`
	Delete  bool
	Env     string `arg:"env" yaml:"env"`
	Help    bool
	JSON    bool   `arg:"env" yaml:"json"`
	IFS     string `arg:"env" yaml:"ifs"`
	Labels  bool   `arg:"env" yaml:"labels"`
	Ping    bool
	Old     bool   `arg:"env" yaml:"old"`
	SetOp   string `arg:"--set-op,env:SET_OP"`
	SetId   string `arg:"--set-id,env:SET_ID"`
	SetSize int    `arg:"--set-size,env:SET_SIZE"`
	Strict  bool   `arg:"env" yaml:"strict"`
	Timeout uint   `arg:"env" yaml:"timeout"`
	Update  bool
	Version 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