Merge pull request #11317 from zenlinTechnofreak/helpSuffixSpace

Help suffix space
This commit is contained in:
Tibor Vass 2015-03-11 10:04:23 -04:00
Родитель 1a5e46ce89 491b63e0da
Коммит 830544044e
2 изменённых файлов: 17 добавлений и 3 удалений

Просмотреть файл

@ -93,10 +93,13 @@ func (cli *DockerCli) Subcmd(name, signature, description string, exitOnError bo
flags := flag.NewFlagSet(name, errorHandling)
flags.Usage = func() {
options := ""
if flags.FlagCountUndeprecated() > 0 {
options = "[OPTIONS] "
if signature != "" {
signature = " " + signature
}
fmt.Fprintf(cli.out, "\nUsage: docker %s %s%s\n\n%s\n\n", name, options, signature, description)
if flags.FlagCountUndeprecated() > 0 {
options = " [OPTIONS]"
}
fmt.Fprintf(cli.out, "\nUsage: docker %s%s%s\n\n%s\n\n", name, options, signature, description)
flags.SetOutput(cli.out)
flags.PrintDefaults()
os.Exit(0)

Просмотреть файл

@ -59,6 +59,11 @@ func TestHelpTextVerify(t *testing.T) {
t.Fatalf("Line is too long(%d chars):\n%s", len(line), line)
}
// All lines should not end with a space
if strings.HasSuffix(line, " ") {
t.Fatalf("Line should not end with a space: %s", line)
}
if scanForHome && strings.Contains(line, `=`+home) {
t.Fatalf("Line should use '%q' instead of %q:\n%s", homedir.GetShortcutString(), home, line)
}
@ -130,6 +135,12 @@ func TestHelpTextVerify(t *testing.T) {
if strings.HasPrefix(line, " -") && strings.HasSuffix(line, ".") {
t.Fatalf("Help for %q should not end with a period: %s", cmd, line)
}
// Options should NOT end with a space
if strings.HasSuffix(line, " ") {
t.Fatalf("Help for %q should not end with a space: %s", cmd, line)
}
}
}