From b07c0fe8d275573a7b63e28fb0bfa9bb4934fa13 Mon Sep 17 00:00:00 2001 From: Jim Powers Date: Wed, 2 May 2018 08:55:01 -0400 Subject: [PATCH] Exposed the `value` accessor in `Context` --- context.go | 2 +- flag_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/context.go b/context.go index 552ee74052..91ee127aec 100644 --- a/context.go +++ b/context.go @@ -166,7 +166,7 @@ func (c *Context) Parent() *Context { } // value returns the value of the flag coressponding to `name` -func (c *Context) value(name string) interface{} { +func (c *Context) Value(name string) interface{} { return c.flagSet.Lookup(name).Value.(flag.Getter).Get() } diff --git a/flag_test.go b/flag_test.go index da9fd731a7..49534bcbf6 100644 --- a/flag_test.go +++ b/flag_test.go @@ -93,8 +93,8 @@ func TestFlagsFromEnv(t *testing.T) { a := App{ Flags: []Flag{test.flag}, Action: func(ctx *Context) error { - if !reflect.DeepEqual(ctx.value(test.flag.GetName()), test.output) { - t.Errorf("expected %+v to be parsed as %+v, instead was %+v", test.input, test.output, ctx.value(test.flag.GetName())) + if !reflect.DeepEqual(ctx.Value(test.flag.GetName()), test.output) { + t.Errorf("expected %+v to be parsed as %+v, instead was %+v", test.input, test.output, ctx.Value(test.flag.GetName())) } return nil },