Skip to content

Commit

Permalink
Fix docs
Browse files Browse the repository at this point in the history
  • Loading branch information
dearchap committed Dec 23, 2023
1 parent 7307084 commit 14c4ec3
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion flag_bool_with_inverse.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (parent *BoolWithInverseFlag) initialize() {
parent.negativeFlag = &BoolFlag{
Category: child.Category,
DefaultText: child.DefaultText,
Sources: NewValueSourceChain(child.Sources.chain...),
Sources: NewValueSourceChain(child.Sources.Chain...),
Usage: child.Usage,
Required: child.Required,
Hidden: child.Hidden,
Expand Down
4 changes: 2 additions & 2 deletions godoc-current.txt
Original file line number Diff line number Diff line change
Expand Up @@ -987,13 +987,13 @@ func NewValueSourceChain(src ...ValueSource) ValueSourceChain

func (vsc *ValueSourceChain) Append(other ValueSourceChain)

func (vsc ValueSourceChain) EnvKeys() []string
func (vsc *ValueSourceChain) EnvKeys() []string

func (vsc *ValueSourceChain) GoString() string

func (vsc *ValueSourceChain) Lookup() (string, bool)

func (vsc ValueSourceChain) LookupWithSource() (string, ValueSource, bool)
func (vsc *ValueSourceChain) LookupWithSource() (string, ValueSource, bool)

func (vsc *ValueSourceChain) String() string

Expand Down
10 changes: 5 additions & 5 deletions testdata/godoc-v3.x.txt
Original file line number Diff line number Diff line change
Expand Up @@ -987,15 +987,15 @@ func NewValueSourceChain(src ...ValueSource) ValueSourceChain

func (vsc *ValueSourceChain) Append(other ValueSourceChain)

func (vsc ValueSourceChain) EnvKeys() []string
func (vsc *ValueSourceChain) EnvKeys() []string

func (vsc ValueSourceChain) GoString() string
func (vsc *ValueSourceChain) GoString() string

func (vsc ValueSourceChain) Lookup() (string, bool)
func (vsc *ValueSourceChain) Lookup() (string, bool)

func (vsc ValueSourceChain) LookupWithSource() (string, ValueSource, bool)
func (vsc *ValueSourceChain) LookupWithSource() (string, ValueSource, bool)

func (vsc ValueSourceChain) String() string
func (vsc *ValueSourceChain) String() string

type VisibleFlag interface {
// IsVisible returns true if the flag is not hidden, otherwise false
Expand Down
26 changes: 13 additions & 13 deletions value_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@ type ValueSource interface {
// allows for lookup where the first ValueSource to resolve is
// returned
type ValueSourceChain struct {
chain []ValueSource
Chain []ValueSource
}

func NewValueSourceChain(src ...ValueSource) ValueSourceChain {
return ValueSourceChain{
chain: src,
Chain: src,
}
}

func (vsc *ValueSourceChain) Append(other ValueSourceChain) {
vsc.chain = append(vsc.chain, other.chain...)
vsc.Chain = append(vsc.Chain, other.Chain...)
}

func (vsc ValueSourceChain) EnvKeys() []string {
func (vsc *ValueSourceChain) EnvKeys() []string {
vals := []string{}

for _, src := range vsc.chain {
for _, src := range vsc.Chain {
if v, ok := src.(*envVarValueSource); ok {
vals = append(vals, v.Key)
}
Expand All @@ -49,7 +49,7 @@ func (vsc ValueSourceChain) EnvKeys() []string {
func (vsc *ValueSourceChain) String() string {
s := []string{}

for _, vs := range vsc.chain {
for _, vs := range vsc.Chain {
s = append(s, vs.String())
}

Expand All @@ -59,7 +59,7 @@ func (vsc *ValueSourceChain) String() string {
func (vsc *ValueSourceChain) GoString() string {
s := []string{}

for _, vs := range vsc.chain {
for _, vs := range vsc.Chain {
s = append(s, vs.GoString())
}

Expand All @@ -71,8 +71,8 @@ func (vsc *ValueSourceChain) Lookup() (string, bool) {
return s, ok
}

func (vsc ValueSourceChain) LookupWithSource() (string, ValueSource, bool) {
for _, src := range vsc.chain {
func (vsc *ValueSourceChain) LookupWithSource() (string, ValueSource, bool) {
for _, src := range vsc.Chain {
if value, found := src.Lookup(); found {
return value, src, true
}
Expand Down Expand Up @@ -104,10 +104,10 @@ func EnvVar(key string) ValueSource {
// EnvVars is a helper function to encapsulate a number of
// envVarValueSource together as a ValueSourceChain
func EnvVars(keys ...string) ValueSourceChain {
vsc := ValueSourceChain{chain: []ValueSource{}}
vsc := ValueSourceChain{Chain: []ValueSource{}}

for _, key := range keys {
vsc.chain = append(vsc.chain, &envVarValueSource{Key: key})
vsc.Chain = append(vsc.Chain, &envVarValueSource{Key: key})
}

return vsc
Expand All @@ -131,10 +131,10 @@ func (f *fileValueSource) GoString() string {
// Files is a helper function to encapsulate a number of
// fileValueSource together as a ValueSourceChain
func Files(paths ...string) ValueSourceChain {
vsc := ValueSourceChain{chain: []ValueSource{}}
vsc := ValueSourceChain{Chain: []ValueSource{}}

for _, path := range paths {
vsc.chain = append(vsc.chain, &fileValueSource{Path: path})
vsc.Chain = append(vsc.Chain, &fileValueSource{Path: path})
}

return vsc
Expand Down
12 changes: 6 additions & 6 deletions value_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,31 +134,31 @@ func TestValueSourceChain(t *testing.T) {
})

t.Run("implements fmt.GoStringer", func(t *testing.T) {
vsc := ValueSourceChain{}
vsc := &ValueSourceChain{}
r := require.New(t)

r.Implements((*fmt.GoStringer)(nil), vsc)
r.Equal("&ValueSourceChain{Chain:{}}", vsc.GoString())

vsc = NewValueSourceChain(&staticValueSource{v: "yahtzee"},
vsc1 := NewValueSourceChain(&staticValueSource{v: "yahtzee"},
&staticValueSource{v: "matzoh"},
)
r.Equal("&ValueSourceChain{Chain:{&staticValueSource{v:\"yahtzee\"},&staticValueSource{v:\"matzoh\"}}}", vsc.GoString())
r.Equal("&ValueSourceChain{Chain:{&staticValueSource{v:\"yahtzee\"},&staticValueSource{v:\"matzoh\"}}}", vsc1.GoString())
})

t.Run("implements fmt.Stringer", func(t *testing.T) {
vsc := ValueSourceChain{}
vsc := &ValueSourceChain{}
r := require.New(t)

r.Implements((*fmt.Stringer)(nil), vsc)
r.Equal("", vsc.String())

vsc = NewValueSourceChain(
vsc1 := NewValueSourceChain(
&staticValueSource{v: "soup"},
&staticValueSource{v: "salad"},
&staticValueSource{v: "pumpkins"},
)
r.Equal("soup,salad,pumpkins", vsc.String())
r.Equal("soup,salad,pumpkins", vsc1.String())
})
}

Expand Down

0 comments on commit 14c4ec3

Please sign in to comment.