Implement flag "resolvers". (#24)
* Propagate errors. * Use junit test output. * Expand role of DecodeContext to include Scanner. * Inject resolved flags as Path elements in the Context. This allows all existing logic to apply seamlessly: hooks, required flags, etc. * Clarify that hooks can be called multiple times.
This commit is contained in:
committed by
Gerald Kaszuba
parent
73064a687f
commit
e9d88d6528
+12
-1
@@ -36,7 +36,7 @@ func TestNamedMapper(t *testing.T) {
|
||||
|
||||
type testMooMapper struct{}
|
||||
|
||||
func (testMooMapper) Decode(ctx *DecoderContext, scan *Scanner, target reflect.Value) error {
|
||||
func (testMooMapper) Decode(ctx *DecodeContext, target reflect.Value) error {
|
||||
target.SetString("MOO")
|
||||
return nil
|
||||
}
|
||||
@@ -64,3 +64,14 @@ func TestDurationMapper(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, time.Second*5, cli.Flag)
|
||||
}
|
||||
|
||||
func TestSplitEscaped(t *testing.T) {
|
||||
require.Equal(t, []string{"a", "b"}, SplitEscaped("a,b", ','))
|
||||
require.Equal(t, []string{"a,b", "c"}, SplitEscaped(`a\,b,c`, ','))
|
||||
}
|
||||
|
||||
func TestJoinEscaped(t *testing.T) {
|
||||
require.Equal(t, `a,b`, JoinEscaped([]string{"a", "b"}, ','))
|
||||
require.Equal(t, `a\,b,c`, JoinEscaped([]string{`a,b`, `c`}, ','))
|
||||
require.Equal(t, JoinEscaped(SplitEscaped(`a\,b,c`, ','), ','), `a\,b,c`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user