Repository: rsteube/carapace
Pull request #761 (2023-04-11 08:25:37)

context rename callbackvalue
- tmp
- Context: renamed CallbackValue to Value



Patch:
diff --git a/command.go b/command.go
index a34e0ed..6de00c4 100644
--- a/command.go
+++ b/command.go
@@ -29,7 +29,7 @@ func addCompletionCommand(cmd *cobra.Command) {
 			}
 
 			if !cmd.HasParent() {
-				panic("missing parent command") // TODO this should never happen
+				panic("missing parent command") // this should never happen
 			}
 
 			if s, err := complete(cmd.Parent(), args); err != nil {
@@ -68,7 +68,7 @@ func addCompletionCommand(cmd *cobra.Command) {
 		ActionCallback(func(c Context) Action {
 			args := []string{"_carapace", "export", ""}
 			args = append(args, c.Args[2:]...)
-			args = append(args, c.CallbackValue)
+			args = append(args, c.Value)
 			return ActionExecCommand(uid.Executable(), args...)(func(output []byte) Action {
 				if string(output) == "" {
 					return ActionValues()
diff --git a/compat.go b/compat.go
index a874d32..69a02fa 100644
--- a/compat.go
+++ b/compat.go
@@ -10,7 +10,7 @@ import (
 func registerValidArgsFunction(cmd *cobra.Command) {
 	if cmd.ValidArgsFunction == nil {
 		cmd.ValidArgsFunction = func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
-			action := storage.getPositional(cmd, len(args)).Invoke(Context{Args: args, CallbackValue: toComplete})
+			action := storage.getPositional(cmd, len(args)).Invoke(Context{Args: args, Value: toComplete})
 			return cobraValuesFor(action), cobraDirectiveFor(action)
 		}
 	}
@@ -20,7 +20,7 @@ func registerFlagCompletion(cmd *cobra.Command) {
 	cmd.Flags().VisitAll(func(f *pflag.Flag) {
 		err := cmd.RegisterFlagCompletionFunc(f.Name, func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
 			a := storage.getFlag(cmd, f.Name)
-			action := a.Invoke(Context{Args: args, CallbackValue: toComplete})
+			action := a.Invoke(Context{Args: args, Value: toComplete})
 			return cobraValuesFor(action), cobraDirectiveFor(action)
 		})
 		if err != nil {
diff --git a/context.go b/context.go
index a125ba0..916958e 100644
--- a/context.go
+++ b/context.go
@@ -15,8 +15,8 @@ import (
 
 // Context provides information during completion.
 type Context struct {
-	// CallbackValue contains the value currently being completed (or part of it during an ActionMultiParts).
-	CallbackValue string
+	// Value contains the value currently being completed (or part of it during an ActionMultiParts).
+	Value string
 	// Args contains the positional arguments of current (sub)command (exclusive the one currently being completed).
 	Args []string
 	// Parts contains the splitted CallbackValue during an ActionMultiParts (exclusive the part currently being completed).
@@ -36,9 +36,9 @@ func NewContext(args ...string) Context {
 	}
 
 	context := Context{
-		CallbackValue: args[len(args)-1],
-		Args:          args[:len(args)-1],
-		Env:           os.Environ(),
+		Value: args[len(args)-1],
+		Args:  args[:len(args)-1],
+		Env:   os.Environ(),
 	}
 
 	if wd, err := os.Getwd(); err == nil {
@@ -48,9 +48,7 @@ func NewContext(args ...string) Context {
 	isGoRun := func() bool { return strings.HasPrefix(os.Args[0], os.TempDir()+"/go-build") }
 	if value, exists := os.LookupEnv("CARAPACE_SANDBOX"); exists && isGoRun() {
 		var m common.Mock
-		if err := json.Unmarshal([]byte(value), &m); err != nil {
-			panic(err.Error()) // TODO
-		}
+		_ = json.Unmarshal([]byte(value), &m)
 		context.Dir = m.Dir
 		context.mockedReplies = m.Replies
 	}
@@ -111,7 +109,7 @@ func expandHome(s string) (string, error) {
 			return zsh.NamedDirectories.Replace(s), nil
 		}
 
-		home, err := os.UserHomeDir() // TODO duplicated code
+		home, err := os.UserHomeDir()
 		if err != nil {
 			return "", err
 		}
diff --git a/defaultActions.go b/defaultActions.go
index e3383bb..0608a18 100644
--- a/defaultActions.go
+++ b/defaultActions.go
@@ -106,7 +106,7 @@ func ActionExecute(cmd *cobra.Command) Action {
 	return ActionCallback(func(c Context) Action {
 		args := []string{"_carapace", "export", cmd.Name()}
 		args = append(args, c.Args...)
-		args = append(args, c.CallbackValue)
+		args = append(args, c.Value)
 		cmd.SetArgs(args)
 
 		Gen(cmd).PreInvoke(func(cmd *cobra.Command, flag *pflag.Flag, action Action) Action {
@@ -213,14 +213,14 @@ func ActionMessage(msg string, args ...interface{}) Action {
 // ActionMultiParts completes multiple parts of words separately where each part is separated by some char (CallbackValue is set to the currently completed part during invocation)
 func ActionMultiParts(divider string, callback func(c Context) Action) Action {
 	return ActionCallback(func(c Context) Action {
-		index := strings.LastIndex(c.CallbackValue, string(divider))
+		index := strings.LastIndex(c.Value, string(divider))
 		prefix := ""
 		if len(divider) == 0 {
-			prefix = c.CallbackValue
-			c.CallbackValue = ""
+			prefix = c.Value
+			c.Value = ""
 		} else if index != -1 {
-			prefix = c.CallbackValue[0 : index+len(divider)]
-			c.CallbackValue = c.CallbackValue[index+len(divider):] // update CallbackValue to only contain the currently completed part
+			prefix = c.Value[0 : index+len(divider)]
+			c.Value = c.Value[index+len(divider):] // update CallbackValue to only contain the currently completed part
 		}
 		parts := strings.Split(prefix, string(divider))
 		if len(parts) > 0 && len(divider) > 0 {
@@ -338,7 +338,7 @@ func ActionStyles(styles ...string) Action {
 				style.BrightWhite, _s(style.BrightWhite),
 			))
 
-			if strings.HasPrefix(c.CallbackValue, "color") {
+			if strings.HasPrefix(c.Value, "color") {
 				for i := 0; i <= 255; i++ {
 					batch = append(batch, ActionStyledValues(
 						fmt.Sprintf("color%v", i), _s(style.XTerm256Color(uint8(i))),
@@ -370,7 +370,7 @@ func ActionStyles(styles ...string) Action {
 				style.BgBrightWhite, _s(style.BgBrightWhite),
 			))
 
-			if strings.HasPrefix(c.CallbackValue, "bg-color") {
+			if strings.HasPrefix(c.Value, "bg-color") {
 				for i := 0; i <= 255; i++ {
 					batch = append(batch, ActionStyledValues(
 						fmt.Sprintf("bg-color%v", i), _s("bg-"+style.XTerm256Color(uint8(i))),
@@ -402,10 +402,10 @@ func ActionExecutables() Action {
 	return ActionCallback(func(c Context) Action {
 		// TODO allow additional descriptions to be registered somewhere for carapace-bin (key, value,...)
 		batch := Batch()
-		manDescriptions := man.Descriptions(c.CallbackValue)
+		manDescriptions := man.Descriptions(c.Value)
 		dirs := strings.Split(os.Getenv("PATH"), string(os.PathListSeparator))
 		for i := len(dirs) - 1; i >= 0; i-- {
-			batch = append(batch, actionDirectoryExecutables(dirs[i], c.CallbackValue, manDescriptions))
+			batch = append(batch, actionDirectoryExecutables(dirs[i], c.Value, manDescriptions))
 		}
 		return batch.ToA()
 	}).Tag("executables")
diff --git a/docs/src/carapace/action/custom.md b/docs/src/carapace/action/custom.md
index eec322a..b91a083 100644
--- a/docs/src/carapace/action/custom.md
+++ b/docs/src/carapace/action/custom.md
@@ -13,7 +13,7 @@ func ActionExample(opts ExampleOpts) carapace.Action {
 		if opts.Static {
 			return carapace.ActionValues("a", "b")
 		}
-		if strings.HasPrefix(c.CallbackValue, "file://") {
+		if strings.HasPrefix(c.Value, "file://") {
 			return carapace.ActionFiles().Invoke(c).Prefix("file://").ToA()
 		}
 		return carapace.ActionValues()
diff --git a/docs/src/carapace/defaultActions/actionCallback.md b/docs/src/carapace/defaultActions/actionCallback.md
index 7ba3277..632bcd3 100644
--- a/docs/src/carapace/defaultActions/actionCallback.md
+++ b/docs/src/carapace/defaultActions/actionCallback.md
@@ -14,7 +14,7 @@ carapace.ActionCallback(func(c carapace.Context) carapace.Action {
 })
 ```
 
-- `c.CallbackValue` provides access to the current (partial) value of the flag or positional argument being completed
+- `c.Value` provides access to the current (partial) value of the flag or positional argument being completed
 - return [ActionValues](./actionValues.md) without arguments to silently skip completion
 - return [ActionMessage](./actionMessage.md) to provide an error message (e.g. failure during invocation of an external command)
 - `c.Args` provides access to the positional arguments of the current subcommand (excluding the one currently being completed)
diff --git a/docs/src/carapace/defaultActions/actionMultiParts.md b/docs/src/carapace/defaultActions/actionMultiParts.md
index 6bf40d2..5037a09 100644
--- a/docs/src/carapace/defaultActions/actionMultiParts.md
+++ b/docs/src/carapace/defaultActions/actionMultiParts.md
@@ -1,7 +1,7 @@
 # ActionMultiParts
 
 [`ActionMultiParts`] completes parts of an argument separately (e.g. `user:group` from chown).
-For this the `Context.CallbackValue` is split with given divider and then updated to only contain the currently completed part.
+For this the `Context.Value` is split with given divider and then updated to only contain the currently completed part.
 `Context.Parts` contains the preceding parts and can be used in a `switch` statement to return the corresponding [Action](../action.md).
 
 > An empty divider splits per character, but be aware that fish will add space suffix for anything other than `/=@:.,`.
@@ -61,6 +61,5 @@ carapace.ActionMultiParts(",", func(cEntries carapace.Context) carapace.Action {
 
 ![](./actionMultiParts-nested.cast)
 
-[`carapace.CallbackValue`]:https://pkg.go.dev/github.com/rsteube/carapace#pkg-variables
 [`ActionMultiParts`]:https://pkg.go.dev/github.com/rsteube/carapace#ActionMultiParts
 [`NoSpace`]:../action/noSpace.md
\ No newline at end of file
diff --git a/internalActions.go b/internalActions.go
index fbda64f..917cccb 100644
--- a/internalActions.go
+++ b/internalActions.go
@@ -14,12 +14,12 @@ import (
 
 func actionPath(fileSuffixes []string, dirOnly bool) Action {
 	return ActionCallback(func(c Context) Action {
-		abs, err := c.Abs(c.CallbackValue)
+		abs, err := c.Abs(c.Value)
 		if err != nil {
 			return ActionMessage(err.Error())
 		}
 
-		displayFolder := filepath.Dir(c.CallbackValue)
+		displayFolder := filepath.Dir(c.Value)
 		if displayFolder == "." {
 			displayFolder = ""
 		} else if !strings.HasSuffix(displayFolder, "/") {
@@ -61,7 +61,7 @@ func actionPath(fileSuffixes []string, dirOnly bool) Action {
 				}
 			}
 		}
-		if strings.HasPrefix(c.CallbackValue, "./") {
+		if strings.HasPrefix(c.Value, "./") {
 			return ActionStyledValues(vals...).Invoke(Context{}).Prefix("./").ToA()
 		}
 		return ActionStyledValues(vals...)
@@ -71,7 +71,7 @@ func actionPath(fileSuffixes []string, dirOnly bool) Action {
 func actionFlags(cmd *cobra.Command) Action {
 	return ActionCallback(func(c Context) Action {
 		flagSet := pflagfork.FlagSet{FlagSet: cmd.Flags()}
-		isShorthandSeries := flagSet.IsShorthandSeries(c.CallbackValue)
+		isShorthandSeries := flagSet.IsShorthandSeries(c.Value)
 
 		vals := make([]string, 0)
 		flagSet.VisitAll(func(f *pflagfork.Flag) {
@@ -100,7 +100,7 @@ func actionFlags(cmd *cobra.Command) Action {
 
 			if isShorthandSeries {
 				if f.Shorthand != "" && f.ShorthandDeprecated == "" {
-					for _, shorthand := range c.CallbackValue[1:] {
+					for _, shorthand := range c.Value[1:] {
 						if shorthandFlag := cmd.Flags().ShorthandLookup(string(shorthand)); shorthandFlag != nil && shorthandFlag.Value.Type() != "bool" && shorthandFlag.Value.Type() != "count" && shorthandFlag.NoOptDefVal == "" {
 							return // abort shorthand flag series if a previous one is not bool or count and requires an argument (no default value)
 						}
@@ -122,7 +122,7 @@ func actionFlags(cmd *cobra.Command) Action {
 		})
 
 		if isShorthandSeries {
-			return ActionStyledValuesDescribed(vals...).Invoke(c).Prefix(c.CallbackValue).ToA().NoSpace('*')
+			return ActionStyledValuesDescribed(vals...).Invoke(c).Prefix(c.Value).ToA().NoSpace('*')
 		}
 		return ActionStyledValuesDescribed(vals...).Invoke(c).ToMultiPartsA(".") // multiparts completion for flags grouped with `.`
 	}).Tag("flags")
diff --git a/invokedAction.go b/invokedAction.go
index 8b11468..1404613 100644
--- a/invokedAction.go
+++ b/invokedAction.go
@@ -87,11 +87,11 @@ func tokenize(s string, dividers ...string) []string {
 //	b := a.ToMultiPartsA("/") // completes segments separately (first one is ["A/", "B/", "C"])
 func (a InvokedAction) ToMultiPartsA(dividers ...string) Action {
 	return ActionCallback(func(c Context) Action {
-		splittedCV := tokenize(c.CallbackValue, dividers...)
+		splittedCV := tokenize(c.Value, dividers...)
 
 		uniqueVals := make(map[string]common.RawValue)
 		for _, val := range a.rawValues {
-			if strings.HasPrefix(val.Value, c.CallbackValue) {
+			if strings.HasPrefix(val.Value, c.Value) {
 				if splitted := tokenize(val.Value, dividers...); len(splitted) >= len(splittedCV) {
 					v := strings.Join(splitted[:len(splittedCV)], "")
 					d := splitted[len(splittedCV)-1]
diff --git a/pkg/sandbox/sandbox.go b/pkg/sandbox/sandbox.go
index c69a1cc..2df1ea0 100644
--- a/pkg/sandbox/sandbox.go
+++ b/pkg/sandbox/sandbox.go
@@ -147,7 +147,7 @@ type run struct {
 
 func (r run) invoke(a carapace.Action) string {
 	meta, rawValues := common.FromInvokedAction(a.Invoke(r.context))
-	rawValues = rawValues.FilterPrefix(r.context.CallbackValue)
+	rawValues = rawValues.FilterPrefix(r.context.Value)
 	sort.Sort(common.ByValue(rawValues))
 
 	m, err := json.MarshalIndent(export.Export{
@@ -188,7 +188,7 @@ func Package(t *testing.T, pkg string) (f func(func(s *Sandbox))) {
 			carapace.ActionCallback(func(c carapace.Context) carapace.Action {
 				args := []string{"run", pkg, "_carapace", "export", ""}
 				args = append(args, c.Args...)
-				args = append(args, c.CallbackValue)
+				args = append(args, c.Value)
 
 				var err error
 				if c.Dir, err = os.Getwd(); err != nil { // `go run` needs to run in actual workdir and not the sandbox dir
diff --git a/traverse.go b/traverse.go
index beb9970..2aa4a9f 100644
--- a/traverse.go
+++ b/traverse.go
@@ -113,17 +113,17 @@ loop:
 	if inFlag != nil && len(inFlag.Args) == 0 && inFlag.Consumes("") {
 		LOG.Printf("removing arg %#v since it is a flag missing its argument\n", toParse[len(toParse)-1])
 		toParse = toParse[:len(toParse)-1]
-	} else if fs.IsShorthandSeries(context.CallbackValue) {
-		LOG.Printf("arg %#v is a shorthand flag series", context.CallbackValue)
+	} else if fs.IsShorthandSeries(context.Value) {
+		LOG.Printf("arg %#v is a shorthand flag series", context.Value)
 		localInFlag := &_inFlag{
-			Flag: fs.LookupArg(context.CallbackValue),
+			Flag: fs.LookupArg(context.Value),
 			Args: []string{},
 		}
-		if localInFlag.Consumes("") && len(context.CallbackValue) > 2 {
+		if localInFlag.Consumes("") && len(context.Value) > 2 {
 			LOG.Printf("removing shorthand %#v from flag series since it is missing its argument\n", localInFlag.Shorthand)
-			toParse = append(toParse, strings.TrimSuffix(context.CallbackValue, localInFlag.Shorthand))
+			toParse = append(toParse, strings.TrimSuffix(context.Value, localInFlag.Shorthand))
 		} else {
-			toParse = append(toParse, context.CallbackValue)
+			toParse = append(toParse, context.Value)
 		}
 
 	}
@@ -144,24 +144,24 @@ loop:
 	switch {
 	// dash argument
 	case common.IsDash(c):
-		LOG.Printf("completing dash for arg %#v\n", context.CallbackValue)
+		LOG.Printf("completing dash for arg %#v\n", context.Value)
 		context.Args = c.Flags().Args()[c.ArgsLenAtDash():]
 		LOG.Printf("context: %#v\n", context.Args)
 
 		return storage.getPositional(c, len(context.Args)), context
 
 	// flag argument
-	case inFlag != nil && inFlag.Consumes(context.CallbackValue):
-		LOG.Printf("completing flag argument of %#v for arg %#v\n", inFlag.Name, context.CallbackValue)
+	case inFlag != nil && inFlag.Consumes(context.Value):
+		LOG.Printf("completing flag argument of %#v for arg %#v\n", inFlag.Name, context.Value)
 		context.Parts = inFlag.Args
 		return storage.getFlag(c, inFlag.Name), context
 
 	// flag
-	case !c.DisableFlagParsing && strings.HasPrefix(context.CallbackValue, "-"):
-		if f := fs.LookupArg(context.CallbackValue); f != nil && f.IsOptarg() && strings.Contains(context.CallbackValue, string(f.OptargDelimiter())) {
-			LOG.Printf("completing optional flag argument for arg %#v\n", context.CallbackValue)
-			prefix, optarg := f.Split(context.CallbackValue)
-			context.CallbackValue = optarg
+	case !c.DisableFlagParsing && strings.HasPrefix(context.Value, "-"):
+		if f := fs.LookupArg(context.Value); f != nil && f.IsOptarg() && strings.Contains(context.Value, string(f.OptargDelimiter())) {
+			LOG.Printf("completing optional flag argument for arg %#v\n", context.Value)
+			prefix, optarg := f.Split(context.Value)
+			context.Value = optarg
 
 			switch f.Value.Type() {
 			case "bool":
@@ -170,12 +170,12 @@ loop:
 				return storage.getFlag(c, f.Name).Prefix(prefix), context
 			}
 		}
-		LOG.Printf("completing flags for arg %#v\n", context.CallbackValue)
+		LOG.Printf("completing flags for arg %#v\n", context.Value)
 		return actionFlags(c), context
 
 	// positional or subcommand
 	default:
-		LOG.Printf("completing positionals and subcommands for arg %#v\n", context.CallbackValue)
+		LOG.Printf("completing positionals and subcommands for arg %#v\n", context.Value)
 		batch := Batch(storage.getPositional(c, len(context.Args)))
 		if c.HasAvailableSubCommands() && len(context.Args) == 0 {
 			batch = append(batch, actionSubcommands(c))


Test patch:
diff --git a/action_test.go b/action_test.go
index 2c86568..d7edca5 100644
--- a/action_test.go
+++ b/action_test.go
@@ -123,7 +123,7 @@ func TestActionDirectories(t *testing.T) {
 			"pkg/", style.Of("fg-default", "bg-default", style.Blue, style.Bold),
 			"third_party/", style.Of("fg-default", "bg-default", style.Blue, style.Bold),
 		).NoSpace('/').Tag("directories").Invoke(Context{}),
-		ActionDirectories().Invoke(Context{CallbackValue: ""}).Filter([]string{"vendor/"}),
+		ActionDirectories().Invoke(Context{Value: ""}).Filter([]string{"vendor/"}),
 	)
 
 	assertEqual(t,
@@ -135,7 +135,7 @@ func TestActionDirectories(t *testing.T) {
 			"pkg/", style.Of("fg-default", "bg-default", style.Blue, style.Bold),
 			"third_party/", style.Of("fg-default", "bg-default", style.Blue, style.Bold),
 		).NoSpace('/').Tag("directories").Invoke(Context{}).Prefix("./"),
-		ActionDirectories().Invoke(Context{CallbackValue: "./"}).Filter([]string{"./vendor/"}),
+		ActionDirectories().Invoke(Context{Value: "./"}).Filter([]string{"./vendor/"}),
 	)
 
 	assertEqual(t,
@@ -143,14 +143,14 @@ func TestActionDirectories(t *testing.T) {
 			"_test/", style.Of("fg-default", "bg-default", style.Blue, style.Bold),
 			"cmd/", style.Of("fg-default", "bg-default", style.Blue, style.Bold),
 		).NoSpace('/').Tag("directories").Invoke(Context{}).Prefix("example/"),
-		ActionDirectories().Invoke(Context{CallbackValue: "example/"}),
+		ActionDirectories().Invoke(Context{Value: "example/"}),
 	)
 
 	assertEqual(t,
 		ActionStyledValues(
 			"cmd/", style.Of("fg-default", "bg-default", style.Blue, style.Bold),
 		).NoSpace('/').Tag("directories").Invoke(Context{}).Prefix("example/"),
-		ActionDirectories().Invoke(Context{CallbackValue: "example/cm"}),
+		ActionDirectories().Invoke(Context{Value: "example/cm"}),
 	)
 }
 
@@ -165,7 +165,7 @@ func TestActionFiles(t *testing.T) {
 			"pkg/", style.Of("fg-default", "bg-default", style.Blue, style.Bold),
 			"third_party/", style.Of("fg-default", "bg-default", style.Blue, style.Bold),
 		).NoSpace('/').Tag("files").Invoke(Context{}),
-		ActionFiles(".md").Invoke(Context{CallbackValue: ""}).Filter([]string{"vendor/"}),
+		ActionFiles(".md").Invoke(Context{Value: ""}).Filter([]string{"vendor/"}),
 	)
 
 	assertEqual(t,
@@ -176,7 +176,7 @@ func TestActionFiles(t *testing.T) {
 			"main.go", style.Of("fg-default", "bg-default"),
 			"main_test.go", style.Of("fg-default", "bg-default"),
 		).NoSpace('/').Tag("files").Invoke(Context{}).Prefix("example/"),
-		ActionFiles().Invoke(Context{CallbackValue: "example/"}).Filter([]string{"example/example"}),
+		ActionFiles().Invoke(Context{Value: "example/"}).Filter([]string{"example/example"}),
 	)
 }
 
@@ -190,7 +190,7 @@ func TestActionFilesChdir(t *testing.T) {
 
 	assertEqual(t,
 		ActionMessage(fmt.Sprintf("not a directory: %v/go.mod", wd(""))).Invoke(Context{}),
-		ActionFiles(".md").Chdir("go.mod").Invoke(Context{CallbackValue: ""}),
+		ActionFiles(".md").Chdir("go.mod").Invoke(Context{Value: ""}),
 	)
 
 	assertEqual(t,
@@ -198,7 +198,7 @@ func TestActionFilesChdir(t *testing.T) {
 			"action.go", style.Of("fg-default", "bg-default"),
 			"snippet.go", style.Of("fg-default", "bg-default"),
 		).NoSpace('/').Tag("files").Invoke(Context{}).Prefix("elvish/"),
-		ActionFiles().Chdir("internal/shell").Invoke(Context{CallbackValue: "elvish/"}),
+		ActionFiles().Chdir("internal/shell").Invoke(Context{Value: "elvish/"}),
 	)
 
 	if newWd, _ := os.Getwd(); oldWd != newWd {
@@ -212,7 +212,7 @@ func TestActionMessage(t *testing.T) {
 
 	assertEqual(t,
 		expected.Invoke(Context{}),
-		ActionMessage("example message").Invoke(Context{CallbackValue: "docs/"}),
+		ActionMessage("example message").Invoke(Context{Value: "docs/"}),
 	)
 }
 
@@ -229,7 +229,7 @@ func TestActionMessageSuppress(t *testing.T) {
 func TestActionExecCommand(t *testing.T) {
 	assertEqual(t,
 		ActionMessage("go unknown: unknown command").NoSpace('/').Invoke(Context{}).Prefix("docs/"),
-		ActionExecCommand("go", "unknown")(func(output []byte) Action { return ActionValues() }).Invoke(Context{CallbackValue: "docs/"}),
+		ActionExecCommand("go", "unknown")(func(output []byte) Action { return ActionValues() }).Invoke(Context{Value: "docs/"}),
 	)
 
 	assertEqual(t,
diff --git a/carapace_test.go b/carapace_test.go
index b1acb6c..de3e567 100644
--- a/carapace_test.go
+++ b/carapace_test.go
@@ -78,83 +78,83 @@ func testContext(t *testing.T, expected Context, args ...string) {
 
 func TestContext(t *testing.T) {
 	testContext(t, Context{
-		CallbackValue: "",
-		Args:          []string{},
-		Parts:         []string{},
-		Env:           []string{},
-		Dir:           wd(""),
+		Value: "",
+		Args:  []string{},
+		Parts: []string{},
+		Env:   []string{},
+		Dir:   wd(""),
 	},
 		"")
 
 	testContext(t, Context{
-		CallbackValue: "",
-		Args:          []string{"pos1"},
-		Parts:         []string{},
-		Env:           []string{},
-		Dir:           wd(""),
+		Value: "",
+		Args:  []string{"pos1"},
+		Parts: []string{},
+		Env:   []string{},
+		Dir:   wd(""),
 	},
 		"pos1", "")
 
 	testContext(t, Context{
-		CallbackValue: "po",
-		Args:          []string{"pos1", "pos2"},
-		Parts:         []string{},
-		Env:           []string{},
-		Dir:           wd(""),
+		Value: "po",
+		Args:  []string{"pos1", "pos2"},
+		Parts: []string{},
+		Env:   []string{},
+		Dir:   wd(""),
 	},
 		"pos1", "pos2", "po")
 
 	testContext(t, Context{
-		CallbackValue: "",
-		Args:          []string{},
-		Parts:         []string{},
-		Env:           []string{},
-		Dir:           wd(""),
+		Value: "",
+		Args:  []string{},
+		Parts: []string{},
+		Env:   []string{},
+		Dir:   wd(""),
 	},
 		"--multiparts", "")
 
 	testContext(t, Context{
-		CallbackValue: "fir",
-		Args:          []string{},
-		Parts:         []string{},
-		Env:           []string{},
-		Dir:           wd(""),
+		Value: "fir",
+		Args:  []string{},
+		Parts: []string{},
+		Env:   []string{},
+		Dir:   wd(""),
 	},
 		"--multiparts", "fir")
 
 	testContext(t, Context{
-		CallbackValue: "seco",
-		Args:          []string{"pos1"},
-		Parts:         []string{"first"},
-		Env:           []string{},
-		Dir:           wd(""),
+		Value: "seco",
+		Args:  []string{"pos1"},
+		Parts: []string{"first"},
+		Env:   []string{},
+		Dir:   wd(""),
 	},
 		"pos1", "--multiparts", "first,seco")
 
 	testContext(t, Context{
-		CallbackValue: "pos",
-		Args:          []string{},
-		Parts:         []string{},
-		Env:           []string{},
-		Dir:           wd(""),
+		Value: "pos",
+		Args:  []string{},
+		Parts: []string{},
+		Env:   []string{},
+		Dir:   wd(""),
 	},
 		"pos")
 
 	testContext(t, Context{
-		CallbackValue: "sec",
-		Args:          []string{},
-		Parts:         []string{"first"},
-		Env:           []string{},
-		Dir:           wd(""),
+		Value: "sec",
+		Args:  []string{},
+		Parts: []string{"first"},
+		Env:   []string{},
+		Dir:   wd(""),
 	},
 		"first:sec")
 
 	testContext(t, Context{
-		CallbackValue: "thi",
-		Args:          []string{"first:second"},
-		Parts:         []string{},
-		Env:           []string{},
-		Dir:           wd(""),
+		Value: "thi",
+		Args:  []string{"first:second"},
+		Parts: []string{},
+		Env:   []string{},
+		Dir:   wd(""),
 	},
 		"first:second", "thi")
 }
diff --git a/defaultActions_test.go b/defaultActions_test.go
index dcb7ef8..1e75d65 100644
--- a/defaultActions_test.go
+++ b/defaultActions_test.go
@@ -38,7 +38,7 @@ func TestActionFlags(t *testing.T) {
 	cmd.Flags().BoolP("beta", "b", false, "")
 
 	cmd.Flag("alpha").Changed = true
-	a := actionFlags(cmd).Invoke(Context{CallbackValue: "-a"})
+	a := actionFlags(cmd).Invoke(Context{Value: "-a"})
 	assertEqual(t, ActionValuesDescribed("b", "").Tag("flags").NoSpace().Invoke(Context{}).Prefix("-a"), a)
 }
 
diff --git a/invokedAction_test.go b/invokedAction_test.go
index 372c9bc..f348c92 100644
--- a/invokedAction_test.go
+++ b/invokedAction_test.go
@@ -20,7 +20,7 @@ func TestToMultiParts(t *testing.T) {
 			"C/d/1()2", "withbrackets", style.Yellow,
 		)
 		a = a.Invoke(Context{}).ToMultiPartsA(delimiter...)
-		if actual := a.Invoke(Context{CallbackValue: cv}).value("export", cv); !strings.Contains(actual, expected) {
+		if actual := a.Invoke(Context{Value: cv}).value("export", cv); !strings.Contains(actual, expected) {
 			t.Errorf("expected '%v' in '%v' for '%v'", expected, actual, cv)
 		}
 	}