add newlines

This commit is contained in:
Roy Olav Purser 2021-06-18 15:07:31 +02:00
parent 7d9f8195b7
commit c7e42dc9c0
Signed by: roypur
GPG Key ID: E14D26A036F21656

View File

@ -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,23 +135,32 @@ func (c *Config) help() {
if len(v.dtype.String()) > max[1] {
max[1] = len(v.dtype.String())
}
}
}
fmt.Println()
for k, v := range c.env {
if v.dtype != TypeNone {
if v.hasdef {
format := fmt.Sprintf("Variable %%-%ds| Type %%-%ds| Default %%s\n", max[0]+3, max[1]+3)
fmt.Printf(format, k, v.dtype, v.defval)
pdef = true
} else {
preq = true
}
}
}
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)
fmt.Printf(format, k, v.dtype)
if pdef {
fmt.Println()
for k, v := range c.env {
if v.dtype != TypeNone {
if v.hasdef {
format := fmt.Sprintf("Variable %%-%ds| Type %%-%ds| Default %%s\n", max[0]+3, max[1]+3)
fmt.Printf(format, k, v.dtype, v.defval)
}
}
}
}
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\n", max[0]+3, max[1]+3)
fmt.Printf(format, k, v.dtype)
}
}
}
}