Track trace values externally to the path.

This allows accumulating mappers to work correctly. This also means
that resolvers are not even triggered if a command-line value is passed,
which is more desirable behaviour.
This commit is contained in:
Alec Thomas
2018-06-13 21:41:55 +10:00
parent c7dca86dad
commit 54386f7fa5
4 changed files with 53 additions and 33 deletions
+2 -2
View File
@@ -352,8 +352,8 @@ func TestHooks(t *testing.T) {
{"ArgAndFlag", "one two --three=three", values{true, "two", "three"}},
}
setOne := func(ctx *Context, path *Path) error { hooked.one = true; return nil }
setTwo := func(ctx *Context, path *Path) error { hooked.two = path.Value.String(); return nil }
setThree := func(ctx *Context, path *Path) error { hooked.three = path.Value.String(); return nil }
setTwo := func(ctx *Context, path *Path) error { hooked.two = ctx.Value(path).String(); return nil }
setThree := func(ctx *Context, path *Path) error { hooked.three = ctx.Value(path).String(); return nil }
p := mustNew(t, &cli,
Hook(&cli.One, setOne),
Hook(&cli.One.Two, setTwo),