diff --git a/flag_bool.go b/flag_bool.go index bdca2b5..3caeb08 100644 --- a/flag_bool.go +++ b/flag_bool.go @@ -102,8 +102,8 @@ func (f *BoolFlag) Apply(set *flag.FlagSet) error { return nil } -// ValueFromContext returns the flag’s value in the given Context. -func (f *BoolFlag) ValueFromContext(ctx *Context) bool { +// Get returns the flag’s value in the given Context. +func (f *BoolFlag) Get(ctx *Context) bool { return ctx.Bool(f.Name) } diff --git a/flag_duration.go b/flag_duration.go index 1de10b1..3452aac 100644 --- a/flag_duration.go +++ b/flag_duration.go @@ -101,8 +101,8 @@ func (f *DurationFlag) Apply(set *flag.FlagSet) error { return nil } -// ValueFromContext returns the flag’s value in the given Context. -func (f *DurationFlag) ValueFromContext(ctx *Context) time.Duration { +// Get returns the flag’s value in the given Context. +func (f *DurationFlag) Get(ctx *Context) time.Duration { return ctx.Duration(f.Name) } diff --git a/flag_float64.go b/flag_float64.go index f2eb040..fc1b3b9 100644 --- a/flag_float64.go +++ b/flag_float64.go @@ -101,8 +101,8 @@ func (f *Float64Flag) Apply(set *flag.FlagSet) error { return nil } -// ValueFromContext returns the flag’s value in the given Context. -func (f *Float64Flag) ValueFromContext(ctx *Context) float64 { +// Get returns the flag’s value in the given Context. +func (f *Float64Flag) Get(ctx *Context) float64 { return ctx.Float64(f.Name) } diff --git a/flag_float64_slice.go b/flag_float64_slice.go index c987688..35cc535 100644 --- a/flag_float64_slice.go +++ b/flag_float64_slice.go @@ -175,8 +175,8 @@ func (f *Float64SliceFlag) Apply(set *flag.FlagSet) error { return nil } -// ValueFromContext returns the flag’s value in the given Context. -func (f *Float64SliceFlag) ValueFromContext(ctx *Context) []float64 { +// Get returns the flag’s value in the given Context. +func (f *Float64SliceFlag) Get(ctx *Context) []float64 { return ctx.Float64Slice(f.Name) } diff --git a/flag_generic.go b/flag_generic.go index 483c7d1..74c896e 100644 --- a/flag_generic.go +++ b/flag_generic.go @@ -104,8 +104,8 @@ func (f GenericFlag) Apply(set *flag.FlagSet) error { return nil } -// ValueFromContext returns the flag’s value in the given Context. -func (f *GenericFlag) ValueFromContext(ctx *Context) interface{} { +// Get returns the flag’s value in the given Context. +func (f *GenericFlag) Get(ctx *Context) interface{} { return ctx.Generic(f.Name) } diff --git a/flag_int.go b/flag_int.go index 642a68b..6929543 100644 --- a/flag_int.go +++ b/flag_int.go @@ -102,8 +102,8 @@ func (f *IntFlag) Apply(set *flag.FlagSet) error { return nil } -// ValueFromContext returns the flag’s value in the given Context. -func (f *IntFlag) ValueFromContext(ctx *Context) int { +// Get returns the flag’s value in the given Context. +func (f *IntFlag) Get(ctx *Context) int { return ctx.Int(f.Name) } diff --git a/flag_int64.go b/flag_int64.go index 6b40374..55d1214 100644 --- a/flag_int64.go +++ b/flag_int64.go @@ -101,8 +101,8 @@ func (f *Int64Flag) Apply(set *flag.FlagSet) error { return nil } -// ValueFromContext returns the flag’s value in the given Context. -func (f *Int64Flag) ValueFromContext(ctx *Context) int64 { +// Get returns the flag’s value in the given Context. +func (f *Int64Flag) Get(ctx *Context) int64 { return ctx.Int64(f.Name) } diff --git a/flag_int64_slice.go b/flag_int64_slice.go index 29e8dc4..212b47b 100644 --- a/flag_int64_slice.go +++ b/flag_int64_slice.go @@ -174,8 +174,8 @@ func (f *Int64SliceFlag) Apply(set *flag.FlagSet) error { return nil } -// ValueFromContext returns the flag’s value in the given Context. -func (f *Int64SliceFlag) ValueFromContext(ctx *Context) []int64 { +// Get returns the flag’s value in the given Context. +func (f *Int64SliceFlag) Get(ctx *Context) []int64 { return ctx.Int64Slice(f.Name) } diff --git a/flag_int_slice.go b/flag_int_slice.go index 4d1741c..82c045d 100644 --- a/flag_int_slice.go +++ b/flag_int_slice.go @@ -185,8 +185,8 @@ func (f *IntSliceFlag) Apply(set *flag.FlagSet) error { return nil } -// ValueFromContext returns the flag’s value in the given Context. -func (f *IntSliceFlag) ValueFromContext(ctx *Context) []int { +// Get returns the flag’s value in the given Context. +func (f *IntSliceFlag) Get(ctx *Context) []int { return ctx.IntSlice(f.Name) } diff --git a/flag_path.go b/flag_path.go index 40c9009..82e540b 100644 --- a/flag_path.go +++ b/flag_path.go @@ -96,8 +96,8 @@ func (f *PathFlag) Apply(set *flag.FlagSet) error { return nil } -// ValueFromContext returns the flag’s value in the given Context. -func (f *PathFlag) ValueFromContext(ctx *Context) string { +// Get returns the flag’s value in the given Context. +func (f *PathFlag) Get(ctx *Context) string { return ctx.Path(f.Name) } diff --git a/flag_string.go b/flag_string.go index 7464a28..258ca92 100644 --- a/flag_string.go +++ b/flag_string.go @@ -97,8 +97,8 @@ func (f *StringFlag) Apply(set *flag.FlagSet) error { return nil } -// ValueFromContext returns the flag’s value in the given Context. -func (f *StringFlag) ValueFromContext(ctx *Context) string { +// Get returns the flag’s value in the given Context. +func (f *StringFlag) Get(ctx *Context) string { return ctx.String(f.Name) } diff --git a/flag_string_slice.go b/flag_string_slice.go index 90e6ebd..79257b6 100644 --- a/flag_string_slice.go +++ b/flag_string_slice.go @@ -186,8 +186,8 @@ func (f *StringSliceFlag) Apply(set *flag.FlagSet) error { return nil } -// ValueFromContext returns the flag’s value in the given Context. -func (f *StringSliceFlag) ValueFromContext(ctx *Context) []string { +// Get returns the flag’s value in the given Context. +func (f *StringSliceFlag) Get(ctx *Context) []string { return ctx.StringSlice(f.Name) } diff --git a/flag_test.go b/flag_test.go index 4862c03..07f6f89 100644 --- a/flag_test.go +++ b/flag_test.go @@ -58,8 +58,8 @@ func TestBoolFlagValueFromContext(t *testing.T) { ctx := NewContext(nil, set, nil) tf := &BoolFlag{Name: "trueflag"} ff := &BoolFlag{Name: "falseflag"} - expect(t, tf.ValueFromContext(ctx), true) - expect(t, ff.ValueFromContext(ctx), false) + expect(t, tf.Get(ctx), true) + expect(t, ff.Get(ctx), false) } func TestFlagsFromEnv(t *testing.T) { @@ -455,7 +455,7 @@ func TestStringFlagValueFromContext(t *testing.T) { set.String("myflag", "foobar", "doc") ctx := NewContext(nil, set, nil) f := &StringFlag{Name: "myflag"} - expect(t, f.ValueFromContext(ctx), "foobar") + expect(t, f.Get(ctx), "foobar") } var pathFlagTests = []struct { @@ -514,7 +514,7 @@ func TestPathFlagValueFromContext(t *testing.T) { set.String("myflag", "/my/path", "doc") ctx := NewContext(nil, set, nil) f := &PathFlag{Name: "myflag"} - expect(t, f.ValueFromContext(ctx), "/my/path") + expect(t, f.Get(ctx), "/my/path") } var envHintFlagTests = []struct { @@ -635,7 +635,7 @@ func TestStringSliceFlagValueFromContext(t *testing.T) { set.Var(NewStringSlice("a", "b", "c"), "myflag", "doc") ctx := NewContext(nil, set, nil) f := &StringSliceFlag{Name: "myflag"} - expect(t, f.ValueFromContext(ctx), []string{"a", "b", "c"}) + expect(t, f.Get(ctx), []string{"a", "b", "c"}) } var intFlagTests = []struct { @@ -692,7 +692,7 @@ func TestIntFlagValueFromContext(t *testing.T) { set.Int("myflag", 42, "doc") ctx := NewContext(nil, set, nil) f := &IntFlag{Name: "myflag"} - expect(t, f.ValueFromContext(ctx), 42) + expect(t, f.Get(ctx), 42) } var int64FlagTests = []struct { @@ -738,7 +738,7 @@ func TestInt64FlagValueFromContext(t *testing.T) { set.Int64("myflag", 42, "doc") ctx := NewContext(nil, set, nil) f := &Int64Flag{Name: "myflag"} - expect(t, f.ValueFromContext(ctx), int64(42)) + expect(t, f.Get(ctx), int64(42)) } var uintFlagTests = []struct { @@ -784,7 +784,7 @@ func TestUintFlagValueFromContext(t *testing.T) { set.Uint("myflag", 42, "doc") ctx := NewContext(nil, set, nil) f := &UintFlag{Name: "myflag"} - expect(t, f.ValueFromContext(ctx), uint(42)) + expect(t, f.Get(ctx), uint(42)) } var uint64FlagTests = []struct { @@ -830,7 +830,7 @@ func TestUint64FlagValueFromContext(t *testing.T) { set.Uint64("myflag", 42, "doc") ctx := NewContext(nil, set, nil) f := &Uint64Flag{Name: "myflag"} - expect(t, f.ValueFromContext(ctx), uint64(42)) + expect(t, f.Get(ctx), uint64(42)) } var durationFlagTests = []struct { @@ -887,7 +887,7 @@ func TestDurationFlagValueFromContext(t *testing.T) { set.Duration("myflag", 42*time.Second, "doc") ctx := NewContext(nil, set, nil) f := &DurationFlag{Name: "myflag"} - expect(t, f.ValueFromContext(ctx), 42*time.Second) + expect(t, f.Get(ctx), 42*time.Second) } var intSliceFlagTests = []struct { @@ -984,7 +984,7 @@ func TestIntSliceFlagValueFromContext(t *testing.T) { set.Var(NewIntSlice(1, 2, 3), "myflag", "doc") ctx := NewContext(nil, set, nil) f := &IntSliceFlag{Name: "myflag"} - expect(t, f.ValueFromContext(ctx), []int{1, 2, 3}) + expect(t, f.Get(ctx), []int{1, 2, 3}) } var int64SliceFlagTests = []struct { @@ -1088,7 +1088,7 @@ func TestInt64SliceFlagValueFromContext(t *testing.T) { set.Var(NewInt64Slice(1, 2, 3), "myflag", "doc") ctx := NewContext(nil, set, nil) f := &Int64SliceFlag{Name: "myflag"} - expect(t, f.ValueFromContext(ctx), []int64{1, 2, 3}) + expect(t, f.Get(ctx), []int64{1, 2, 3}) } var float64FlagTests = []struct { @@ -1145,7 +1145,7 @@ func TestFloat64FlagValueFromContext(t *testing.T) { set.Float64("myflag", 1.23, "doc") ctx := NewContext(nil, set, nil) f := &Float64Flag{Name: "myflag"} - expect(t, f.ValueFromContext(ctx), 1.23) + expect(t, f.Get(ctx), 1.23) } var float64SliceFlagTests = []struct { @@ -1194,7 +1194,7 @@ func TestFloat64SliceFlagValueFromContext(t *testing.T) { set.Var(NewFloat64Slice(1.23, 4.56), "myflag", "doc") ctx := NewContext(nil, set, nil) f := &Float64SliceFlag{Name: "myflag"} - expect(t, f.ValueFromContext(ctx), []float64{1.23, 4.56}) + expect(t, f.Get(ctx), []float64{1.23, 4.56}) } var genericFlagTests = []struct { @@ -1250,7 +1250,7 @@ func TestGenericFlagValueFromContext(t *testing.T) { set.Var(&Parser{"abc", "def"}, "myflag", "doc") ctx := NewContext(nil, set, nil) f := &GenericFlag{Name: "myflag"} - expect(t, f.ValueFromContext(ctx), &Parser{"abc", "def"}) + expect(t, f.Get(ctx), &Parser{"abc", "def"}) } func TestParseMultiString(t *testing.T) { @@ -2286,7 +2286,7 @@ func TestTimestampFlagValueFromContext(t *testing.T) { set.Var(NewTimestamp(now), "myflag", "doc") ctx := NewContext(nil, set, nil) f := &TimestampFlag{Name: "myflag"} - expect(t, f.ValueFromContext(ctx), &now) + expect(t, f.Get(ctx), &now) } type flagDefaultTestCase struct { diff --git a/flag_timestamp.go b/flag_timestamp.go index a3b230e..872f855 100644 --- a/flag_timestamp.go +++ b/flag_timestamp.go @@ -164,8 +164,8 @@ func (f *TimestampFlag) Apply(set *flag.FlagSet) error { return nil } -// ValueFromContext returns the flag’s value in the given Context. -func (f *TimestampFlag) ValueFromContext(ctx *Context) *time.Time { +// Get returns the flag’s value in the given Context. +func (f *TimestampFlag) Get(ctx *Context) *time.Time { return ctx.Timestamp(f.Name) } diff --git a/flag_uint.go b/flag_uint.go index b074c4e..358e22f 100644 --- a/flag_uint.go +++ b/flag_uint.go @@ -101,8 +101,8 @@ func (f *UintFlag) GetEnvVars() []string { return f.EnvVars } -// ValueFromContext returns the flag’s value in the given Context. -func (f *UintFlag) ValueFromContext(ctx *Context) uint { +// Get returns the flag’s value in the given Context. +func (f *UintFlag) Get(ctx *Context) uint { return ctx.Uint(f.Name) } diff --git a/flag_uint64.go b/flag_uint64.go index e79b1a7..844dfc9 100644 --- a/flag_uint64.go +++ b/flag_uint64.go @@ -101,8 +101,8 @@ func (f *Uint64Flag) GetEnvVars() []string { return f.EnvVars } -// ValueFromContext returns the flag’s value in the given Context. -func (f *Uint64Flag) ValueFromContext(ctx *Context) uint64 { +// Get returns the flag’s value in the given Context. +func (f *Uint64Flag) Get(ctx *Context) uint64 { return ctx.Uint64(f.Name) }