Pretty the help text
This modifies the "docker help" text so that it is no wider than 80 chars and each description fits on one line. This will also try to use ~ when possible Added a test to make sure we don't go over 80 chars again. Added a test to make sure we use ~ Applied rules/tests to all docker commands - not just main help text Closes #10214 Signed-off-by: Doug Davis <dug@us.ibm.com>
This commit is contained in:
parent
810a000d6b
commit
9bc2b3482b
1 changed files with 12 additions and 1 deletions
|
@ -86,6 +86,7 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"runtime"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
@ -503,6 +504,10 @@ 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")
|
||||
}
|
||||
f.VisitAll(func(flag *Flag) {
|
||||
format := " -%s=%s"
|
||||
if _, ok := flag.Value.(*stringValue); ok {
|
||||
|
@ -516,7 +521,13 @@ func (f *FlagSet) PrintDefaults() {
|
|||
}
|
||||
}
|
||||
if len(names) > 0 {
|
||||
fmt.Fprintf(writer, format, strings.Join(names, ", -"), flag.DefValue)
|
||||
val := flag.DefValue
|
||||
|
||||
if home != "" && strings.HasPrefix(val, home) {
|
||||
val = "~" + val[len(home):]
|
||||
}
|
||||
|
||||
fmt.Fprintf(writer, format, strings.Join(names, ", -"), val)
|
||||
for i, line := range strings.Split(flag.Usage, "\n") {
|
||||
if i != 0 {
|
||||
line = " " + line
|
||||
|
|
Loading…
Reference in a new issue