Auth methods CLI (#277)

This commit is contained in:
Jeff Mitchell authored and GitHub committed 2020-08-18 17:46:34 -04:00
1 parent 041e1f9fd3
commit adfc5681be
41 files changed
+951 -192

No files matched your search

+23
View File
@@ -54,6 +54,29 @@ func WrapForHelpText(lines []string) string {
return strings.Join(ret, "\n")
}
func WrapMap(prefixSpaces, maxLengthOverride int, input map[string]interface{}) string {
maxKeyLength := maxLengthOverride
if maxKeyLength == 0 {
for k := range input {
if len(k) > maxKeyLength {
maxKeyLength = len(k)
}
}
}
var ret []string
for k, v := range input {
spaces := maxKeyLength - len(k)
ret = append(ret, fmt.Sprintf("%s%s%s%s",
strings.Repeat(" ", prefixSpaces),
fmt.Sprintf("%s: ", k),
strings.Repeat(" ", spaces),
fmt.Sprintf("%v", v)),
)
}
return strings.Join(ret, "\n")
}
type FormatOptions struct {
Format string
}