config

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2019 License: MIT Imports: 12 Imported by: 17

Documentation

Overview

Package config provides config structures, and a mechanism that merges sources such that the global config file, a project local config file and command-line flags.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Edit

func Edit() error

Edit opens the project local config file with an editor. If the local config file is missing, Edit creates a new local config file. $EDITOR is used as an editor if it is configured. Else, Vim is used.

Types

type Config

type Config struct {
	Default *Default `toml:"default"`
	Meta    *Meta    `toml:"meta"`
	REPL    *REPL    `toml:"repl"`
	Server  *Server  `toml:"server"`
	Log     *Log     `toml:"log"`
	Request *Request `toml:"request"`
}

Each TOML key must be equal the field name in the lower-case. It is a limitation of spf13/viper.

func Get

func Get(fs *pflag.FlagSet) (*Config, error)

Get returns the config which loaded from the global and local config files, and command-line flags passed as an argument. Note that fs must have been parsed.

The order of priority is flags > local > global.

type Default

type Default struct {
	ProtoPath []string `toml:"protoPath"`
	ProtoFile []string `toml:"protoFile"`
	Package   string   `toml:"package"`
	Service   string   `toml:"service"`
}
type Header map[string][]string

type Log

type Log struct {
	Prefix string `toml:"prefix"`
}

type Meta

type Meta struct {
	ConfigVersion string `toml:"configVersion"`
	AutoUpdate    bool   `toml:"autoUpdate"`
	UpdateLevel   string `toml:"updateLevel"`
}

type REPL

type REPL struct {
	PromptFormat      string `toml:"promptFormat"`
	InputPromptFormat string `toml:"inputPromptFormat"`

	ColoredOutput bool `toml:"coloredOutput"`

	ShowSplashText bool   `toml:"showSplashText"`
	SplashTextPath string `toml:"splashTextPath"`

	HistorySize int `toml:"historySize"`
}

type Request

type Request struct {
	Header      Header `toml:"header"`
	Web         bool   `toml:"web"`
	CACertFile  string `toml:"caCertFile"`
	CertFile    string `toml:"certFile"`
	CertKeyFile string `toml:"certKeyFile"`
}

type Server

type Server struct {
	Host       string `toml:"host"`
	Port       string `toml:"port"`
	Reflection bool   `toml:"reflection"`
	TLS        bool   `toml:"tls"`
	Name       string `toml:"name"`
}

Jump to

Keyboard shortcuts

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