help function
This commit is contained in:
parent
ab7e9ada6f
commit
8dfd5378c0
23
envconf.go
23
envconf.go
@ -117,6 +117,29 @@ func (c *Config) Parse() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Config) Help() {
|
||||||
|
max := 0
|
||||||
|
for k, v := range c.env {
|
||||||
|
if v.dtype != TypeNone {
|
||||||
|
if len(k) > max {
|
||||||
|
max = len(k)
|
||||||
|
}
|
||||||
|
if len(v.dtype.String()) > max {
|
||||||
|
max = len(v.dtype.String())
|
||||||
|
}
|
||||||
|
if len(v.value) > max {
|
||||||
|
max = len(v.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for k, v := range c.env {
|
||||||
|
if v.dtype != TypeNone {
|
||||||
|
format := fmt.Sprintf("Variable %%%ds|Type %%%ds|Default %%s\n", max, max)
|
||||||
|
fmt.Printf(format, k, v.dtype, v.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Status prints out failures that occured while parsing the environment to os.Stderr.
|
// Status prints out failures that occured while parsing the environment to os.Stderr.
|
||||||
// Variables that have been defined without a default value and are
|
// Variables that have been defined without a default value and are
|
||||||
// missing from the environment will be considered a failure.
|
// missing from the environment will be considered a failure.
|
||||||
|
Loading…
Reference in New Issue
Block a user