Skip to content

Commit

Permalink
Fix more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dearchap committed Jun 26, 2023
1 parent afdcf77 commit 983228e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"flag"
"fmt"
"log"
"strings"
)

Expand Down Expand Up @@ -156,6 +157,10 @@ func (cCtx *Context) Value(name string) interface{} {
if g, ok := f.(ValueGetter); ok {
return g.GetFlagValue().Get()
}
if g, ok := f.(flag.Getter); ok {
log.Printf("%v", g.Get())
return g.Get()
}
}
return nil
}
Expand Down
8 changes: 7 additions & 1 deletion flag_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ type fnValue struct {

func (f fnValue) Get() any { return f.v.Get() }
func (f fnValue) Set(s string) error { return f.fn(s) }
func (f fnValue) String() string { return f.v.String() }
func (f fnValue) String() string {
if f.v == nil {
return ""
}
return f.v.String()
}

func (f fnValue) Serialize() string {
if s, ok := f.v.(Serializer); ok {
return s.Serialize()
Expand Down

0 comments on commit 983228e

Please sign in to comment.