зеркало из https://github.com/microsoft/docker.git
Merge pull request #11317 from zenlinTechnofreak/helpSuffixSpace
Help suffix space
This commit is contained in:
Коммит
830544044e
|
@ -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)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче