add newlines
This commit is contained in:
parent
7d9f8195b7
commit
c7e42dc9c0
15
envconf.go
15
envconf.go
@ -76,6 +76,7 @@ func (c *Config) DefineDefault(key string, val string, dtype DataType) {
|
||||
entry.dtype = dtype
|
||||
entry.empty = false
|
||||
entry.defval = val
|
||||
entry.hasdef = true
|
||||
c.env[upper] = entry
|
||||
} else {
|
||||
var entry cEntry
|
||||
@ -84,6 +85,7 @@ func (c *Config) DefineDefault(key string, val string, dtype DataType) {
|
||||
entry.empty = false
|
||||
entry.value = val
|
||||
entry.defval = val
|
||||
entry.hasdef = true
|
||||
c.env[upper] = entry
|
||||
}
|
||||
}
|
||||
@ -123,6 +125,8 @@ func (c *Config) Parse() {
|
||||
|
||||
func (c *Config) help() {
|
||||
max := make([]int, 2, 2)
|
||||
preq := false
|
||||
pdef := false
|
||||
for k, v := range c.env {
|
||||
if v.dtype != TypeNone {
|
||||
if len(k) > max[0] {
|
||||
@ -131,8 +135,14 @@ func (c *Config) help() {
|
||||
if len(v.dtype.String()) > max[1] {
|
||||
max[1] = len(v.dtype.String())
|
||||
}
|
||||
if v.hasdef {
|
||||
pdef = true
|
||||
} else {
|
||||
preq = true
|
||||
}
|
||||
}
|
||||
}
|
||||
if pdef {
|
||||
fmt.Println()
|
||||
for k, v := range c.env {
|
||||
if v.dtype != TypeNone {
|
||||
@ -142,15 +152,18 @@ func (c *Config) help() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if preq {
|
||||
fmt.Println()
|
||||
for k, v := range c.env {
|
||||
if v.dtype != TypeNone {
|
||||
if !v.hasdef {
|
||||
format := fmt.Sprintf("Variable %%-%ds| Type %%-%ds| Required", max[0]+3, max[1]+3)
|
||||
format := fmt.Sprintf("Variable %%-%ds| Type %%-%ds| Required\n", max[0]+3, max[1]+3)
|
||||
fmt.Printf(format, k, v.dtype)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user