Documentation ¶
Overview ¶
Copyright 2015 Gravitational, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2015 Gravitational, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2015 Gravitational, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- func NewCommandLineApp(v interface{}) (*kingpin.Application, error)
- func ParseCommandLine(v interface{}, args []string) error
- func ParseEnv(v interface{}) error
- func ParseYAML(data []byte, cfg interface{}) error
- func SaveYAML(filename string, cfg interface{}) error
- type CLISetter
- type EnvSetter
- type KeyVal
- type KeyValSlice
- type StringSetter
Constants ¶
const Tag = "config"
Variables ¶
This section is empty.
Functions ¶
func NewCommandLineApp ¶
func NewCommandLineApp(v interface{}) (*kingpin.Application, error)
NewCommandLineApp generates a command line parsing tool based on the struct that was passed in as a parameter
func ParseCommandLine ¶
ParseCommandLine takes a pointer to a function and attempts to initialize it from environment variables.
func ParseEnv ¶
func ParseEnv(v interface{}) error
ParseEnv takes a pointer to a struct and attempts to initialize it from environment variables.
func ParseYAML ¶
ParseYAML parses yaml-encoded byte string into the struct passed to the function. EnableTemplating() argument allows to treat configuration file as a template for example, it will support {{env "VAR"}} - that will substitute environment variable "VAR" and pass it to YAML file parser
Types ¶
type EnvSetter ¶
Setter is an interface that properties of struct can implement to initialize the value of any struct from string
type KeyVal ¶
KeyVal is map that can parse itself from string, represented as a comma-separated list of keys and values "key:val,key:val"
func KeyValParam ¶
func KeyValParam(s kingpin.Settings) *KeyVal
KeyValParam accepts a kingpin setting parameter and returns kingpin-compatible value
type KeyValSlice ¶
KeyValSlice is a list of key value strings
func (*KeyValSlice) Set ¶
func (kv *KeyValSlice) Set(v string) error
Set accepts string with arguments in the form "key:val,key2:val2"
func (*KeyValSlice) SetEnv ¶
func (kv *KeyValSlice) SetEnv(v string) error
SetEnv sets the value from environment variable using json encoding
func (*KeyValSlice) String ¶
func (kv *KeyValSlice) String() string
String returns a string with comma separated key-values: "key:val,key2:val2"
type StringSetter ¶
StringSetter is an interface that allows to set variable from any string