From b53c79d6268afb01e79605e076992b5000a39e88 Mon Sep 17 00:00:00 2001 From: Lynn Date: Mon, 13 Jan 2020 09:40:12 -0800 Subject: [PATCH] Revert "Merge pull request #741 from corruptmemory/expose-value" This reverts commit 108d39a38e17130fe4de61b94ec443bbb265fec4, reversing changes made to 754ed1bf85da93060d928f9eca0bce83eb5f19be. --- context.go | 4 ++-- context_test.go | 4 ++-- flag_test.go | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/context.go b/context.go index 74ed51912e..64195df2fe 100644 --- a/context.go +++ b/context.go @@ -106,8 +106,8 @@ func (c *Context) Lineage() []*Context { return lineage } -// Value returns the value of the flag corresponding to `name` -func (c *Context) Value(name string) interface{} { +// value returns the value of the flag corresponding to `name` +func (c *Context) value(name string) interface{} { return c.flagSet.Lookup(name).Value.(flag.Getter).Get() } diff --git a/context_test.go b/context_test.go index ccf8846505..9030354334 100644 --- a/context_test.go +++ b/context_test.go @@ -3,8 +3,8 @@ package cli import ( "context" "flag" - "os" "sort" + "os" "strings" "testing" "time" @@ -328,7 +328,7 @@ func TestContextPropagation(t *testing.T) { parent := NewContext(nil, nil, nil) parent.Context = context.WithValue(context.Background(), "key", "val") ctx := NewContext(nil, nil, parent) - val := ctx.Context.Value("key") + val := ctx.Value("key") if val == nil { t.Fatal("expected a parent context to be inherited but got nil") } diff --git a/flag_test.go b/flag_test.go index f0c444e58f..5362bf44f8 100644 --- a/flag_test.go +++ b/flag_test.go @@ -121,8 +121,8 @@ func TestFlagsFromEnv(t *testing.T) { a := App{ Flags: []Flag{test.flag}, Action: func(ctx *Context) error { - if !reflect.DeepEqual(ctx.Value(test.flag.Names()[0]), test.output) { - t.Errorf("ex:%01d expected %q to be parsed as %#v, instead was %#v", i, test.input, test.output, ctx.Value(test.flag.Names()[0])) + if !reflect.DeepEqual(ctx.value(test.flag.Names()[0]), test.output) { + t.Errorf("ex:%01d expected %q to be parsed as %#v, instead was %#v", i, test.input, test.output, ctx.value(test.flag.Names()[0])) } return nil },