Skip to content

Commit

Permalink
ran gofmt on everything
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Picciano committed Sep 19, 2013
1 parent 23d7583 commit 36717d4
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 35 deletions.
10 changes: 5 additions & 5 deletions src/flagconfig/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package flagconfig
import (
"fmt"
"github.com/droundy/goopt"
"os"
"github.com/mediocregopher/flagconfig/src/flagconfig/params"
"os"
)

type FlagConfig struct {
projname string
projname string
fullConfig map[string]params.Param
}

Expand All @@ -18,7 +18,7 @@ type FlagConfig struct {
// * Get found parameters using GetStr, GetInt, etc...
func New(projname string) *FlagConfig {
return &FlagConfig{
projname: projname,
projname: projname,
fullConfig: map[string]params.Param{},
}
}
Expand Down Expand Up @@ -77,7 +77,7 @@ func (f *FlagConfig) GetStrs(name string) []string {
// arguments and a possible configuration file
func (f *FlagConfig) Parse() error {

for _,param := range f.fullConfig {
for _, param := range f.fullConfig {
param.CLA()
}

Expand Down Expand Up @@ -109,7 +109,7 @@ func (f *FlagConfig) Parse() error {
return err
}

for _,param := range f.fullConfig {
for _, param := range f.fullConfig {
if vals, ok := configFileMap[param.Name()]; ok {
for i := range vals {
param.ConfFile(vals[i])
Expand Down
4 changes: 2 additions & 2 deletions src/flagconfig/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ func (f *FlagConfig) dumpExampleConfig(projname string) string {

for name, param := range f.fullConfig {
buffer.WriteString("# " + param.Description() + "\n")
if defaults,ok := param.DefaultAsStrings(); ok {
if defaults, ok := param.DefaultAsStrings(); ok {
for i := range defaults {
buffer.WriteString(name + ": " + defaults[i] + "\n")
}
} else {
buffer.WriteString(name + ": <required>\n")
buffer.WriteString(name + ": <required>\n")
}
buffer.WriteString("\n")
}
Expand Down
16 changes: 8 additions & 8 deletions src/flagconfig/params/int.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package params

import (
"errors"
"github.com/droundy/goopt"
"strconv"
"errors"
)

type intParam struct {
name, description string
name, description string
defaultVal, cliVal, confVal *int
finalVal int
finalVal int
}

func NewInt(name, description string, def int, required bool) *intParam {
Expand All @@ -19,9 +19,9 @@ func NewInt(name, description string, def int, required bool) *intParam {
*defVal = def
}
return &intParam{
name: name,
name: name,
description: description,
defaultVal: defVal,
defaultVal: defVal,
}
}

Expand All @@ -33,11 +33,11 @@ func (p *intParam) Description() string {
return p.description
}

func (p *intParam) DefaultAsStrings() ([]string,bool) {
func (p *intParam) DefaultAsStrings() ([]string, bool) {
if p.defaultVal != nil {
return []string{strconv.Itoa(*p.defaultVal)},true
return []string{strconv.Itoa(*p.defaultVal)}, true
} else {
return nil,false
return nil, false
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/flagconfig/params/param.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type Param interface {

// The default value (or multiple values) of the parameter as a string, with
// a boolean to indicate if it even has one
DefaultAsStrings() ([]string,bool)
DefaultAsStrings() ([]string, bool)

// Make the appropriate call to the CLA handler for this param. The handler
// will probably return a pointer of some sort which will be populated once
Expand Down
16 changes: 8 additions & 8 deletions src/flagconfig/params/string.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package params

import (
"github.com/droundy/goopt"
"errors"
"github.com/droundy/goopt"
)

type stringParam struct {
name, description string
name, description string
defaultVal, cliVal, confVal *string
finalVal string
finalVal string
}

func NewString(name, description string, def string, required bool) *stringParam {
Expand All @@ -18,9 +18,9 @@ func NewString(name, description string, def string, required bool) *stringParam
*defVal = def
}
return &stringParam{
name: name,
name: name,
description: description,
defaultVal: defVal,
defaultVal: defVal,
}
}

Expand All @@ -32,11 +32,11 @@ func (p *stringParam) Description() string {
return p.description
}

func (p *stringParam) DefaultAsStrings() ([]string,bool) {
func (p *stringParam) DefaultAsStrings() ([]string, bool) {
if p.defaultVal != nil {
return []string{*p.defaultVal},true
return []string{*p.defaultVal}, true
} else {
return nil,false
return nil, false
}
}

Expand Down
22 changes: 11 additions & 11 deletions src/flagconfig/params/strings.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package params

import (
"github.com/droundy/goopt"
"errors"
"github.com/droundy/goopt"
)

type stringsParam struct {
name, description string
name, description string
defaultVal, confVal []string
cliVal *[]string
finalVal []string
cliVal *[]string
finalVal []string
}

func NewStrings(name, description string, def []string, required bool) *stringsParam {
Expand All @@ -18,9 +18,9 @@ func NewStrings(name, description string, def []string, required bool) *stringsP
defVal = def
}
return &stringsParam{
name: name,
name: name,
description: description,
defaultVal: defVal,
defaultVal: defVal,
}
}

Expand All @@ -32,7 +32,7 @@ func (p *stringsParam) Description() string {
return p.description
}

func (p *stringsParam) DefaultAsStrings() ([]string,bool) {
func (p *stringsParam) DefaultAsStrings() ([]string, bool) {
return p.defaultVal, p.defaultVal != nil
}

Expand All @@ -46,14 +46,14 @@ func (p *stringsParam) CLA() {

func (p *stringsParam) ConfFile(val string) {
if p.confVal == nil {
p.confVal = make([]string,0,4)
p.confVal = make([]string, 0, 4)
}
p.confVal = append(p.confVal,val)
p.confVal = append(p.confVal, val)
}

func (p *stringsParam) Post() error {
cliSet := p.cliVal != nil && *p.cliVal != nil && len(*p.cliVal) > 0
if cliSet && !stringSlicesEqual(*p.cliVal,p.defaultVal) {
if cliSet && !stringSlicesEqual(*p.cliVal, p.defaultVal) {
p.finalVal = *p.cliVal
} else if p.confVal != nil {
p.finalVal = p.confVal
Expand All @@ -66,7 +66,7 @@ func (p *stringsParam) Post() error {
return nil
}

func stringSlicesEqual (a, b []string) bool {
func stringSlicesEqual(a, b []string) bool {
if len(a) != len(b) {
return false
}
Expand Down

0 comments on commit 36717d4

Please sign in to comment.