Fix:(issue_1293) Wrap usage text for commands
This commit is contained in:
parent
445734dd4b
commit
b539ee7dc6
29
help_test.go
29
help_test.go
@ -895,6 +895,35 @@ App UsageText`,
|
||||
}
|
||||
}
|
||||
|
||||
func TestShowAppHelp_CommandMultiLine_UsageText(t *testing.T) {
|
||||
app := &App{
|
||||
UsageText: `This is a
|
||||
multi
|
||||
line
|
||||
App UsageText`,
|
||||
Commands: []*Command{
|
||||
{
|
||||
Name: "frobbly",
|
||||
Aliases: []string{"frb1", "frbb2", "frl2"},
|
||||
Usage: "this is a long help output for the run command, long usage \noutput, long usage output, long usage output, long usage output\noutput, long usage output, long usage output",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
output := &bytes.Buffer{}
|
||||
app.Writer = output
|
||||
|
||||
_ = app.Run([]string{"foo"})
|
||||
|
||||
expected := `frobbly, frb1, frbb2, frl2 this is a long help output for the run command, long usage
|
||||
output, long usage output, long usage output, long usage output
|
||||
output, long usage output, long usage output`
|
||||
|
||||
if !strings.Contains(output.String(), expected) {
|
||||
t.Errorf("expected output to include usage text; got: %q", output.String())
|
||||
}
|
||||
}
|
||||
|
||||
func TestHideHelpCommand(t *testing.T) {
|
||||
app := &App{
|
||||
HideHelpCommand: true,
|
||||
|
@ -22,7 +22,7 @@ AUTHOR{{with $length := len .Authors}}{{if ne 1 $length}}S{{end}}{{end}}:
|
||||
COMMANDS:{{range .VisibleCategories}}{{if .Name}}
|
||||
{{.Name}}:{{range .VisibleCommands}}
|
||||
{{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}}{{else}}{{range .VisibleCommands}}
|
||||
{{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}}{{end}}{{end}}{{end}}{{if .VisibleFlagCategories}}
|
||||
{{$s := join .Names ", "}}{{$v := offset $s 5}}{{$s}}{{"\t"}}{{wrap .Usage $v}}{{end}}{{end}}{{end}}{{end}}{{if .VisibleFlagCategories}}
|
||||
|
||||
GLOBAL OPTIONS:{{range .VisibleFlagCategories}}
|
||||
{{if .Name}}{{.Name}}
|
||||
@ -77,7 +77,7 @@ DESCRIPTION:
|
||||
COMMANDS:{{range .VisibleCategories}}{{if .Name}}
|
||||
{{.Name}}:{{range .VisibleCommands}}
|
||||
{{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}}{{else}}{{range .VisibleCommands}}
|
||||
{{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}}{{end}}{{end}}{{if .VisibleFlags}}
|
||||
{{$s := join .Names ", "}}{{$v := offset $s 5}}{{$s}}{{"\t"}}{{wrap .Usage $v}}{{end}}{{end}}{{end}}{{if .VisibleFlags}}
|
||||
|
||||
OPTIONS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
|
Loading…
Reference in New Issue
Block a user