Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Go formatted code

  • Loading branch information...
commit 5e1a98db213b6631951e33aa4336610ca7486ba8 1 parent 6b60249
Jesse van den Kieboom authored committed
2  commander.go
View
@@ -19,7 +19,7 @@ func (x *Commander) sortedNames() []string {
return ret
}
-func (x *Commander) EachCommand(cb func (command string, grp *Group)) {
+func (x *Commander) EachCommand(cb func(command string, grp *Group)) {
for k, v := range x.Commands {
cb(k, v)
6 group.go
View
@@ -39,7 +39,7 @@ type Group struct {
// Groups embedded in this group
EmbeddedGroups []*Group
- IsCommand bool
+ IsCommand bool
LongDescription string
data interface{}
@@ -56,8 +56,8 @@ type Command interface {
// arguments.
func NewGroup(name string, data interface{}) *Group {
ret := &Group{
- Commander: Commander {
- Commands: make(map[string]*Group),
+ Commander: Commander{
+ Commands: make(map[string]*Group),
},
Name: name,
2  group_private.go
View
@@ -2,10 +2,10 @@ package flags
import (
"reflect"
+ "sort"
"strings"
"unicode/utf8"
"unsafe"
- "sort"
)
func (g *Group) lookupByName(name string, ini bool) (*Option, string) {
8 help.go
View
@@ -109,8 +109,8 @@ func (p *Parser) WriteHelp(writer io.Writer) {
if len(p.currentCommandString) > 0 {
fmt.Fprintf(wr, " %s [%s-OPTIONS]",
- strings.Join(p.currentCommandString, " "),
- p.currentCommandString[len(p.currentCommandString)-1])
+ strings.Join(p.currentCommandString, " "),
+ p.currentCommandString[len(p.currentCommandString)-1])
}
fmt.Fprintln(wr)
@@ -132,7 +132,7 @@ func (p *Parser) WriteHelp(writer io.Writer) {
seen := make(map[*Group]bool)
- writeHelp := func (index int, grp *Group) {
+ writeHelp := func(index int, grp *Group) {
if len(grp.Options) == 0 || seen[grp] {
return
}
@@ -178,7 +178,7 @@ func (p *Parser) WriteHelp(writer io.Writer) {
cmd := commander.Commands[name]
if len(cmd.Name) > 0 {
- pad := strings.Repeat(" ", maxnamelen - len(name))
+ pad := strings.Repeat(" ", maxnamelen-len(name))
fmt.Fprintf(wr, "%s %s", pad, cmd.Name)
}
6 man.go
View
@@ -1,10 +1,10 @@
package flags
import (
- "io"
- "time"
"fmt"
+ "io"
"strings"
+ "time"
)
func (x *Parser) formatForMan(wr io.Writer, s string) {
@@ -79,7 +79,7 @@ func (x *Parser) writeManPageCommand(wr io.Writer, command string, grp *Group) {
x.writeManPageOptions(wr, grp)
for k, v := range grp.Commander.Commands {
- x.writeManPageCommand(wr, command + " " + k, v)
+ x.writeManPageCommand(wr, command+" "+k, v)
}
}
2  option.go
View
@@ -46,7 +46,7 @@ type Option struct {
Required bool
// The name of the struct field by which this option is represented.
- FieldName string
+ FieldName string
value reflect.Value
options reflect.StructTag
8 parser.go
View
@@ -35,7 +35,7 @@ type Parser struct {
Options Options
- currentCommand *Group
+ currentCommand *Group
currentCommandString []string
}
@@ -113,7 +113,7 @@ func NewParser(data interface{}, options Options) *Parser {
// option groups later (see Parser.AddGroup).
func NewNamedParser(appname string, options Options, groups ...*Group) *Parser {
ret := &Parser{
- Commander: Commander {
+ Commander: Commander{
Commands: make(map[string]*Group),
},
@@ -341,7 +341,7 @@ func (p *Parser) ParseArgs(args []string) ([]string, error) {
p.Groups = append([]*Group{helpgrp}, p.Groups...)
// Also append the help group to every command
- p.Commander.EachCommand(func (command string, grp *Group) {
+ p.Commander.EachCommand(func(command string, grp *Group) {
grp.EmbeddedGroups = append([]*Group{helpgrp}, grp.EmbeddedGroups...)
})
@@ -389,7 +389,7 @@ func (p *Parser) ParseArgs(args []string) ([]string, error) {
p.currentCommand = cmdgroup
p.currentCommandString = append(p.currentCommandString,
- arg)
+ arg)
commands = cmdgroup.Commands
} else {
Please sign in to comment.
Something went wrong with that request. Please try again.