diff options
| author | Petter Rasmussen | 2016-02-21 01:09:05 +0100 | 
|---|---|---|
| committer | Petter Rasmussen | 2016-02-21 01:09:05 +0100 | 
| commit | 1e2026d06b6288df38a9fd5b1938a6392c6b1fe5 (patch) | |
| tree | 787a9e5e5cbaf921231cfd5a4389ed10eddb0085 | |
| parent | 78207dc0823431ba86fd9179df808b7ab90d97bb (diff) | |
| download | gdrive-1e2026d06b6288df38a9fd5b1938a6392c6b1fe5.tar.bz2 | |
Indent help
| -rw-r--r-- | handlers_meta.go | 25 | 
1 files changed, 19 insertions, 6 deletions
| diff --git a/handlers_meta.go b/handlers_meta.go index 67d80ca..eebdbce 100644 --- a/handlers_meta.go +++ b/handlers_meta.go @@ -1,8 +1,10 @@  package main  import ( +	"os"  	"fmt"  	"strings" +    "text/tabwriter"      "./cli"  ) @@ -11,11 +13,16 @@ func printVersion(ctx cli.Context) {  }  func printHelp(ctx cli.Context) { -    fmt.Printf("%s usage:\n\n", Name) +    w := new(tabwriter.Writer) +    w.Init(os.Stdout, 0, 0, 3, ' ', 0) + +    fmt.Fprintf(w, "%s usage:\n\n", Name)      for _, h := range ctx.Handlers() { -        fmt.Printf("%s %s  (%s)\n", Name, h.Pattern, h.Description) +        fmt.Fprintf(w, "%s %s\t%s\n", Name, h.Pattern, h.Description)      } + +    w.Flush()  }  func printCommandHelp(ctx cli.Context) { @@ -35,18 +42,24 @@ func printCommandPrefixHelp(ctx cli.Context, prefix ...string) {          ExitF("Command not found")      } -    fmt.Printf("%s %s  (%s)\n", Name, handler.Pattern, handler.Description) +    w := new(tabwriter.Writer) +    w.Init(os.Stdout, 0, 0, 3, ' ', 0) + +    fmt.Fprintf(w, "%s\n", handler.Description) +    fmt.Fprintf(w, "%s %s\n", Name, handler.Pattern)      for _, group := range handler.FlagGroups { -        fmt.Printf("\n%s:\n", group.Name) +        fmt.Fprintf(w, "\n%s:\n", group.Name)          for _, flag := range group.Flags {              boolFlag, isBool := flag.(cli.BoolFlag)              if isBool && boolFlag.OmitValue { -                fmt.Printf("  %s  (%s)\n", strings.Join(flag.GetPatterns(), ", "), flag.GetDescription()) +                fmt.Fprintf(w, "  %s\t%s\n", strings.Join(flag.GetPatterns(), ", "), flag.GetDescription())              } else { -                fmt.Printf("  %s <%s>  (%s)\n", strings.Join(flag.GetPatterns(), ", "), flag.GetName(), flag.GetDescription()) +                fmt.Fprintf(w, "  %s <%s>\t%s\n", strings.Join(flag.GetPatterns(), ", "), flag.GetName(), flag.GetDescription())              }          }      } + +    w.Flush()  }  func getHandler(handlers []*cli.Handler, prefix []string) *cli.Handler { | 
