v0.9.12 Latest Latest

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

Go to latest
Published: Mar 6, 2020 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      = 10000 // 10s
	DEFAULT_RETRY        = 0


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


func DefaultTrace

func DefaultTrace() string

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:ES_ADDR" yaml:"addr"`
	Config      string `arg:"env:ES_CONFIG"`
	Debug       bool   `arg:"env:ES_DEBUG" yaml:"debug"`
	Delete      bool
	DeleteLabel bool   `arg:"--delete-label"`
	Env         string `arg:"env:ES_ENV" yaml:"env"`
	Help        bool
	JSON        bool   `arg:"env:ES_JSON" yaml:"json"`
	IFS         string `arg:"env" yaml:"ifs"`
	Labels      bool   `arg:"env:ES_LABELS" yaml:"labels"`
	Old         bool   `arg:"env:ES_OLD" yaml:"old"`
	Retry       uint   `arg:"env:ES_RETRY" yaml:"retry"`
	RetryWait   string `arg:"--retry-wait,env:ES_RETRY_WAIT" yaml:"retry_wait"`
	SetOp       string `arg:"--set-op,env:ES_SET_OP"`
	SetId       string `arg:"--set-id,env:ES_SET_ID"`
	SetSize     int    `arg:"--set-size,env:ES_SET_SIZE"`
	Strict      bool   `arg:"env:ES_STRICT" yaml:"strict"`
	Timeout     uint   `arg:"env:ES_TIMEOUT" yaml:"timeout"`
	Trace       string `arg:"env:ES_TRACE" yaml:"trace"`
	Update      bool
	Unique      bool `arg:"-u"`
	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