1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Shorten printed Windows paths on docker help cmd

This makes use of `%USERPROFILE%` as a substitute for
`~` on Windows and prints shorter strings for default
cert paths etc.

Also removes string escaping/quotes around default
path values printed in `docker help` command as they
are not really necessary and adds double backslashes
(\\) on windows.

Signed-off-by: Ahmet Alp Balkan <ahmetalpbalkan@gmail.com>
This commit is contained in:
Ahmet Alp Balkan 2015-02-18 13:32:42 -08:00
parent 8ca37e4760
commit 1c9b37cb96
2 changed files with 11 additions and 24 deletions

View file

@ -1,23 +1,19 @@
package main
import (
"os"
"os/exec"
"runtime"
"strings"
"testing"
"unicode"
"github.com/docker/docker/pkg/homedir"
)
func TestMainHelpWidth(t *testing.T) {
// Make sure main help text fits within 80 chars and that
// on non-windows system we use ~ when possible (to shorten things)
var home string
if runtime.GOOS != "windows" {
home = os.Getenv("HOME")
}
home := homedir.Get()
helpCmd := exec.Command(dockerBinary, "help")
out, ec, err := runCommandWithOutput(helpCmd)
if err != nil || ec != 0 {
@ -27,9 +23,10 @@ func TestMainHelpWidth(t *testing.T) {
for _, line := range lines {
if len(line) > 80 {
t.Fatalf("Line is too long(%d chars):\n%s", len(line), line)
}
if home != "" && strings.Contains(line, home) {
t.Fatalf("Line should use ~ instead of %q:\n%s", home, line)
t.Fatalf("Line should use '%q' instead of %q:\n%s", homedir.GetShortcutString(), home, line)
}
}
logDone("help - verify main width")
@ -39,11 +36,7 @@ func TestCmdHelpWidth(t *testing.T) {
// Make sure main help text fits within 80 chars and that
// on non-windows system we use ~ when possible (to shorten things)
var home string
if runtime.GOOS != "windows" {
home = os.Getenv("HOME")
}
home := homedir.Get()
// Pull the list of commands from the "Commands:" section of docker help
helpCmd := exec.Command(dockerBinary, "help")
out, ec, err := runCommandWithOutput(helpCmd)
@ -82,7 +75,7 @@ func TestCmdHelpWidth(t *testing.T) {
t.Fatalf("Help for %q is too long(%d chars):\n%s", command, len(line), line)
}
if home != "" && strings.Contains(line, home) {
t.Fatalf("Help for %q should use ~ instead of %q on:\n%s", command, home, line)
t.Fatalf("Help for %q should use home shortcut instead of %q on:\n%s", command, home, line)
}
}
}