Repository: rsteube/carapace (go)

Issue:
support multipart completion for flag names
Some commands like [gum](https://github.com/charmbracelet/gum) have a large amount of flags that are `grouped` using a delimiter.
MultiPart completion should be supported here for better overview with a configurable delimiter (`.` enabled as default?).
This implicitly sets `nospace` though which is inconvenient so supporting conditional `nospace` would be good.

![2022-11-19T12:05:26,773138006+01:00](https://user-images.githubusercontent.com/9090290/202847819-5fba744d-3172-48b4-b427-b6c11ca21b43.png)

![2022-11-19T12:05:38,567836840+01:00](https://user-images.githubusercontent.com/9090290/202847836-5d3fb2ae-1ca3-42e5-b707-04bb8800d1ff.png)


Pull request:
actionFlags: multipart completion for flags as default
fix #598

Patch:
diff --git a/README.md b/README.md
index 564d160..d2b5229 100644
--- a/README.md
+++ b/README.md
@@ -48,6 +48,5 @@ See [carapace-bin](https://github.com/rsteube/carapace-bin) for examples.
 - [carapace-pflag](https://github.com/rsteube/carapace-pflag) Drop-in replacement for spf13/pflag with support for non-posix variants
 - [carapace-spec](https://github.com/rsteube/carapace-spec) define simple completions using a spec file
 - [carapace-spec-clap](https://github.com/rsteube/carapace-spec-clap) spec generation for clap-rs/clap
-- [carapace-spec-kong](https://github.com/rsteube/carapace-spec-kong) spec generation for alecthomas/kong
 
 [cobra]:https://github.com/spf13/cobra
diff --git a/internalActions.go b/internalActions.go
index 9f79edf..c455e77 100644
--- a/internalActions.go
+++ b/internalActions.go
@@ -115,12 +115,7 @@ func actionFlags(cmd *cobra.Command) Action {
 		if isShorthandSeries {
 			return ActionValuesDescribed(vals...).Invoke(c).Prefix(c.CallbackValue).ToA().NoSpace('*')
 		}
-		for i := 0; i < len(vals); i = i + 2 { // TODO experimental - hardcoded multiparts completion if flags are "grouped" with `.`
-			if strings.Contains(vals[i], ".") {
-				return ActionValuesDescribed(vals...).Invoke(c).ToMultiPartsA(".")
-			}
-		}
-		return ActionValuesDescribed(vals...)
+		return ActionValuesDescribed(vals...).Invoke(c).ToMultiPartsA(".") // multiparts completion for flags grouped with `.`
 	}).Tag("flags")
 }
 


Test patch:
diff --git a/example/cmd/root_test.go b/example/cmd/root_test.go
index 7d0d2cc..a78f2e2 100644
--- a/example/cmd/root_test.go
+++ b/example/cmd/root_test.go
@@ -98,33 +98,33 @@ func TestRoot(t *testing.T) {
 				"-p", "Help message for persistentFlag",
 				"--toggle", "Help message for toggle",
 				"-t", "Help message for toggle",
-			).Tag("flags"))
+			).NoSpace('.').Tag("flags"))
 
 		s.Run("--").
 			Expect(carapace.ActionValuesDescribed(
 				"--array", "multiflag",
 				"--persistentFlag", "Help message for persistentFlag",
 				"--toggle", "Help message for toggle",
-			).Tag("flags"))
+			).NoSpace('.').Tag("flags"))
 
 		s.Run("--a").
 			Expect(carapace.ActionValuesDescribed(
 				"--array", "multiflag",
-			).Tag("flags"))
+			).NoSpace('.').Tag("flags"))
 
 		s.Run("--array").
 			Expect(carapace.ActionValuesDescribed(
 				"--array", "multiflag",
-			).Tag("flags"))
+			).NoSpace('.').Tag("flags"))
 
 		s.Run("--array", "", "--a").
 			Expect(carapace.ActionValuesDescribed(
 				"--array", "multiflag",
-			).Tag("flags"))
+			).NoSpace('.').Tag("flags"))
 
 		s.Run("-a", "", "--a").
 			Expect(carapace.ActionValuesDescribed(
 				"--array", "multiflag",
-			).Tag("flags"))
+			).NoSpace('.').Tag("flags"))
 	})
 }