Add HelpValueFormatter as discussed in #60 (#61)

Fixes #60 .
This commit is contained in:
Rene Zbinden
2020-02-21 10:24:19 +01:00
committed by GitHub
parent 73ecfde9b2
commit 7b000bd775
7 changed files with 78 additions and 60 deletions
-11
View File
@@ -7,17 +7,6 @@ import (
var interpolationRegex = regexp.MustCompile(`((?:\${([[:alpha:]_][[:word:]]*))(?:=([^}]+))?})|(\$)|([^$]+)`)
// Returns true if the variable "v" is interpolated in "s".
func interpolationHasVar(s string, v string) bool {
matches := interpolationRegex.FindAllStringSubmatch(s, -1)
for _, match := range matches {
if name := match[2]; name == v {
return true
}
}
return false
}
// Interpolate variables from vars into s for substrings in the form ${var} or ${var=default}.
func interpolate(s string, vars map[string]string) (string, error) {
out := ""