mcfg: ensure all usages end in a period when printing help to cli
This commit is contained in:
parent
6adfbdbcfb
commit
f02f2904b0
@ -175,8 +175,13 @@ func (cli SourceCLI) printHelp(w io.Writer, pM map[string]Param) {
|
||||
fmt.Fprintf(w, " (Default: %s)", defVal)
|
||||
}
|
||||
fmt.Fprintf(w, "\n")
|
||||
if p.Usage != "" {
|
||||
fmt.Fprintln(w, "\t"+p.Usage)
|
||||
if usage := p.Usage; usage != "" {
|
||||
// make all usages end with a period, because I say so
|
||||
usage = strings.TrimSpace(usage)
|
||||
if !strings.HasSuffix(usage, ".") {
|
||||
usage += "."
|
||||
}
|
||||
fmt.Fprintln(w, "\t"+usage)
|
||||
}
|
||||
}
|
||||
fmt.Fprintf(w, "\n")
|
||||
|
@ -15,8 +15,8 @@ import (
|
||||
|
||||
func TestSourceCLIHelp(t *T) {
|
||||
ctx := mctx.New()
|
||||
Int(ctx, "foo", 5, "Test int param")
|
||||
Bool(ctx, "bar", "Test bool param")
|
||||
Int(ctx, "foo", 5, "Test int param ") // trailing space should be trimmed
|
||||
Bool(ctx, "bar", "Test bool param.")
|
||||
String(ctx, "baz", "baz", "Test string param")
|
||||
RequiredString(ctx, "baz2", "")
|
||||
RequiredString(ctx, "baz3", "")
|
||||
@ -33,13 +33,13 @@ func TestSourceCLIHelp(t *T) {
|
||||
--baz3 (Required)
|
||||
|
||||
--bar (Flag)
|
||||
Test bool param
|
||||
Test bool param.
|
||||
|
||||
--baz (Default: "baz")
|
||||
Test string param
|
||||
Test string param.
|
||||
|
||||
--foo (Default: 5)
|
||||
Test int param
|
||||
Test int param.
|
||||
|
||||
`
|
||||
assert.Equal(t, exp, buf.String())
|
||||
|
Loading…
Reference in New Issue
Block a user