diff --git a/mflag/flag.go b/mflag/flag.go index cbdd5ea..edb17a2 100644 --- a/mflag/flag.go +++ b/mflag/flag.go @@ -86,12 +86,13 @@ import ( "fmt" "io" "os" - "runtime" "sort" "strconv" "strings" "text/tabwriter" "time" + + "github.com/docker/docker/pkg/homedir" ) // ErrHelp is the error returned if the flag -help is invoked but no such flag is defined. @@ -504,16 +505,9 @@ func Set(name, value string) error { // otherwise, the default values of all defined flags in the set. func (f *FlagSet) PrintDefaults() { writer := tabwriter.NewWriter(f.Out(), 20, 1, 3, ' ', 0) - var home string - if runtime.GOOS != "windows" { - home = os.Getenv("HOME") - } + home := homedir.Get() f.VisitAll(func(flag *Flag) { format := " -%s=%s" - if _, ok := flag.Value.(*stringValue); ok { - // put quotes on the value - format = " -%s=%q" - } names := []string{} for _, name := range flag.Names { if name[0] != '#' { @@ -524,7 +518,7 @@ func (f *FlagSet) PrintDefaults() { val := flag.DefValue if home != "" && strings.HasPrefix(val, home) { - val = "~" + val[len(home):] + val = homedir.GetShortcutString() + val[len(home):] } fmt.Fprintf(writer, format, strings.Join(names, ", -"), val)