Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Go formatted code

  • Loading branch information...
commit 5e1a98db213b6631951e33aa4336610ca7486ba8 1 parent 6b60249
Jesse van den Kieboom authored committed
2  commander.go
@@ -19,7 +19,7 @@ func (x *Commander) sortedNames() []string {
19 19 return ret
20 20 }
21 21
22   -func (x *Commander) EachCommand(cb func (command string, grp *Group)) {
  22 +func (x *Commander) EachCommand(cb func(command string, grp *Group)) {
23 23 for k, v := range x.Commands {
24 24 cb(k, v)
25 25
6 group.go
@@ -39,7 +39,7 @@ type Group struct {
39 39 // Groups embedded in this group
40 40 EmbeddedGroups []*Group
41 41
42   - IsCommand bool
  42 + IsCommand bool
43 43 LongDescription string
44 44
45 45 data interface{}
@@ -56,8 +56,8 @@ type Command interface {
56 56 // arguments.
57 57 func NewGroup(name string, data interface{}) *Group {
58 58 ret := &Group{
59   - Commander: Commander {
60   - Commands: make(map[string]*Group),
  59 + Commander: Commander{
  60 + Commands: make(map[string]*Group),
61 61 },
62 62
63 63 Name: name,
2  group_private.go
@@ -2,10 +2,10 @@ package flags
2 2
3 3 import (
4 4 "reflect"
  5 + "sort"
5 6 "strings"
6 7 "unicode/utf8"
7 8 "unsafe"
8   - "sort"
9 9 )
10 10
11 11 func (g *Group) lookupByName(name string, ini bool) (*Option, string) {
8 help.go
@@ -109,8 +109,8 @@ func (p *Parser) WriteHelp(writer io.Writer) {
109 109
110 110 if len(p.currentCommandString) > 0 {
111 111 fmt.Fprintf(wr, " %s [%s-OPTIONS]",
112   - strings.Join(p.currentCommandString, " "),
113   - p.currentCommandString[len(p.currentCommandString)-1])
  112 + strings.Join(p.currentCommandString, " "),
  113 + p.currentCommandString[len(p.currentCommandString)-1])
114 114 }
115 115
116 116 fmt.Fprintln(wr)
@@ -132,7 +132,7 @@ func (p *Parser) WriteHelp(writer io.Writer) {
132 132
133 133 seen := make(map[*Group]bool)
134 134
135   - writeHelp := func (index int, grp *Group) {
  135 + writeHelp := func(index int, grp *Group) {
136 136 if len(grp.Options) == 0 || seen[grp] {
137 137 return
138 138 }
@@ -178,7 +178,7 @@ func (p *Parser) WriteHelp(writer io.Writer) {
178 178 cmd := commander.Commands[name]
179 179
180 180 if len(cmd.Name) > 0 {
181   - pad := strings.Repeat(" ", maxnamelen - len(name))
  181 + pad := strings.Repeat(" ", maxnamelen-len(name))
182 182 fmt.Fprintf(wr, "%s %s", pad, cmd.Name)
183 183 }
184 184
6 man.go
... ... @@ -1,10 +1,10 @@
1 1 package flags
2 2
3 3 import (
4   - "io"
5   - "time"
6 4 "fmt"
  5 + "io"
7 6 "strings"
  7 + "time"
8 8 )
9 9
10 10 func (x *Parser) formatForMan(wr io.Writer, s string) {
@@ -79,7 +79,7 @@ func (x *Parser) writeManPageCommand(wr io.Writer, command string, grp *Group) {
79 79 x.writeManPageOptions(wr, grp)
80 80
81 81 for k, v := range grp.Commander.Commands {
82   - x.writeManPageCommand(wr, command + " " + k, v)
  82 + x.writeManPageCommand(wr, command+" "+k, v)
83 83 }
84 84 }
85 85
2  option.go
@@ -46,7 +46,7 @@ type Option struct {
46 46 Required bool
47 47
48 48 // The name of the struct field by which this option is represented.
49   - FieldName string
  49 + FieldName string
50 50
51 51 value reflect.Value
52 52 options reflect.StructTag
8 parser.go
@@ -35,7 +35,7 @@ type Parser struct {
35 35
36 36 Options Options
37 37
38   - currentCommand *Group
  38 + currentCommand *Group
39 39 currentCommandString []string
40 40 }
41 41
@@ -113,7 +113,7 @@ func NewParser(data interface{}, options Options) *Parser {
113 113 // option groups later (see Parser.AddGroup).
114 114 func NewNamedParser(appname string, options Options, groups ...*Group) *Parser {
115 115 ret := &Parser{
116   - Commander: Commander {
  116 + Commander: Commander{
117 117 Commands: make(map[string]*Group),
118 118 },
119 119
@@ -341,7 +341,7 @@ func (p *Parser) ParseArgs(args []string) ([]string, error) {
341 341 p.Groups = append([]*Group{helpgrp}, p.Groups...)
342 342
343 343 // Also append the help group to every command
344   - p.Commander.EachCommand(func (command string, grp *Group) {
  344 + p.Commander.EachCommand(func(command string, grp *Group) {
345 345 grp.EmbeddedGroups = append([]*Group{helpgrp}, grp.EmbeddedGroups...)
346 346 })
347 347
@@ -389,7 +389,7 @@ func (p *Parser) ParseArgs(args []string) ([]string, error) {
389 389 p.currentCommand = cmdgroup
390 390
391 391 p.currentCommandString = append(p.currentCommandString,
392   - arg)
  392 + arg)
393 393
394 394 commands = cmdgroup.Commands
395 395 } else {

0 comments on commit 5e1a98d

Please sign in to comment.
Something went wrong with that request. Please try again.