diff --git a/completers/cfdisk_completer/cmd/root.go b/completers/cfdisk_completer/cmd/root.go index d0640ee5c0..22ada700fa 100644 --- a/completers/cfdisk_completer/cmd/root.go +++ b/completers/cfdisk_completer/cmd/root.go @@ -39,8 +39,9 @@ func init() { func ActionBlockDevicesAndFiles() carapace.Action { return carapace.ActionCallback(func(c carapace.Context) carapace.Action { - blockDevices := fs.ActionBlockDevices().Invoke(c) - files := carapace.ActionFiles().Invoke(c) - return blockDevices.Merge(files).ToA() + return carapace.Batch( + fs.ActionBlockDevices(), + carapace.ActionFiles(), + ).Invoke(c).Merge().ToA() }) } diff --git a/completers/fdisk_completer/cmd/root.go b/completers/fdisk_completer/cmd/root.go index c5333bd1f7..d4e3b9b9c7 100644 --- a/completers/fdisk_completer/cmd/root.go +++ b/completers/fdisk_completer/cmd/root.go @@ -69,8 +69,9 @@ func init() { func ActionBlockDevicesAndFiles() carapace.Action { return carapace.ActionCallback(func(c carapace.Context) carapace.Action { - blockDevices := fs.ActionBlockDevices().Invoke(c) - files := carapace.ActionFiles().Invoke(c) - return blockDevices.Merge(files).ToA() + return carapace.Batch( + fs.ActionBlockDevices(), + carapace.ActionFiles(), + ).Invoke(c).Merge().ToA() }) } diff --git a/completers/flutter_completer/cmd/root.go b/completers/flutter_completer/cmd/root.go index 403e55136b..855ffec227 100644 --- a/completers/flutter_completer/cmd/root.go +++ b/completers/flutter_completer/cmd/root.go @@ -26,9 +26,10 @@ func init() { carapace.Gen(rootCmd).FlagCompletion(carapace.ActionMap{ "device-id": carapace.ActionCallback(func(c carapace.Context) carapace.Action { - devices := action.ActionDevices().Invoke(c) - emulators := action.ActionEmulators().Invoke(c) - return devices.Merge(emulators).ToA() + return carapace.Batch( + action.ActionDevices(), + action.ActionEmulators(), + ).Invoke(c).Merge().ToA() }), }) } diff --git a/completers/gh_completer/cmd/pr_checks.go b/completers/gh_completer/cmd/pr_checks.go index ed9b76761b..0fcffbcf05 100644 --- a/completers/gh_completer/cmd/pr_checks.go +++ b/completers/gh_completer/cmd/pr_checks.go @@ -18,9 +18,10 @@ func init() { carapace.Gen(pr_checksCmd).PositionalCompletion( carapace.ActionCallback(func(c carapace.Context) carapace.Action { - pullRequests := action.ActionPullRequests(pr_checksCmd, action.PullRequestOpts{Open: true}).Invoke(c) - branches := action.ActionBranches(pr_checksCmd).Invoke(c) - return pullRequests.Merge(branches).ToA() + return carapace.Batch( + action.ActionPullRequests(pr_checksCmd, action.PullRequestOpts{Open: true}), + action.ActionBranches(pr_checksCmd), + ).Invoke(c).Merge().ToA() }), ) } diff --git a/completers/glab_completer/cmd/action/mergeRequest.go b/completers/glab_completer/cmd/action/mergeRequest.go index fab4096bb9..e7ff8d1a9f 100644 --- a/completers/glab_completer/cmd/action/mergeRequest.go +++ b/completers/glab_completer/cmd/action/mergeRequest.go @@ -34,8 +34,9 @@ func ActionMergeRequests(cmd *cobra.Command, state string) carapace.Action { func ActionMergeRequestsAndBranches(cmd *cobra.Command, state string) carapace.Action { return carapace.ActionCallback(func(c carapace.Context) carapace.Action { - branches := ActionBranches(cmd).Invoke(c) - mergeRequests := ActionMergeRequests(cmd, state).Invoke(c) - return branches.Merge(mergeRequests).Filter(c.Args).ToA() + return carapace.Batch( + ActionBranches(cmd), + ActionMergeRequests(cmd, state), + ).Invoke(c).Merge().ToA() }) } diff --git a/completers/glab_completer/cmd/action/repoOverride.go b/completers/glab_completer/cmd/action/repoOverride.go index 16315059dc..f1aaf971d3 100644 --- a/completers/glab_completer/cmd/action/repoOverride.go +++ b/completers/glab_completer/cmd/action/repoOverride.go @@ -31,16 +31,17 @@ func ActionRepo(cmd *cobra.Command) carapace.Action { case 0: return carapace.ActionValues(configHosts...).Invoke(c).Suffix("/").ToA() case 1: - // TODO goroutine - users := ActionUsers(cmd).Invoke(c).Suffix("/") - groups := ActionGroups(cmd).Invoke(c).Suffix("/") - return users.Merge(groups).ToA() + return carapace.Batch( + ActionUsers(cmd), + ActionGroups(cmd), + ).Invoke(c).Merge().Suffix("/").ToA() case 2: - // TODO goroutine - subgroups := ActionSubgroups(cmd, c.Parts[1]).Invoke(c).Suffix("/") - groupProjects := ActionGroupProjects(cmd, c.Parts[1]).Invoke(c) - userProjects := ActionUserProjects(cmd, c.Parts[1]).Invoke(c) - return subgroups.Merge(groupProjects, userProjects).ToA() + b := carapace.Batch( + ActionSubgroups(cmd, c.Parts[1]), + ActionGroupProjects(cmd, c.Parts[1]), + ActionUserProjects(cmd, c.Parts[1]), + ).Invoke(c) + return b[0].Suffix("/").Merge(b[1:]...).ToA() // ActionSubgroups needs `/` suffix case 3: groupProjects := ActionGroupProjects(cmd, strings.Join(c.Parts[1:], "/")).Invoke(c) return groupProjects.ToA() diff --git a/completers/glab_completer/cmd/repo_archive.go b/completers/glab_completer/cmd/repo_archive.go index ba80819941..0954811805 100644 --- a/completers/glab_completer/cmd/repo_archive.go +++ b/completers/glab_completer/cmd/repo_archive.go @@ -20,9 +20,10 @@ func init() { carapace.Gen(repo_archiveCmd).FlagCompletion(carapace.ActionMap{ "format": carapace.ActionValues("tar.gz", "tar.bz2", "tbz", "tbz2", "tb2", "bz2", "tar", "zip"), "sha": carapace.ActionCallback(func(c carapace.Context) carapace.Action { - branches := action.ActionBranches(repo_archiveCmd).Invoke(c) - tags := action.ActionTags(repo_archiveCmd).Invoke(c) - return branches.Merge(tags).ToA() // TODO sha + return carapace.Batch( + action.ActionBranches(repo_archiveCmd), + action.ActionTags(repo_archiveCmd), + ).Invoke(c).Merge().ToA() // TODO sha }), }) diff --git a/completers/java_completer/cmd/root.go b/completers/java_completer/cmd/root.go index 30e3702512..25e05a786e 100644 --- a/completers/java_completer/cmd/root.go +++ b/completers/java_completer/cmd/root.go @@ -220,14 +220,13 @@ func ActionClasspathClasses(cmd *cobra.Command) carapace.Action { } } - actions := carapace.ActionValues().Invoke(c) + actions := make([]carapace.Action, 0) for _, file := range files { if strings.HasSuffix(file, ".jar") || strings.HasSuffix(file, ".zip") { - a := action.ActionJarFileClasses(file) - actions = actions.Merge(a.Invoke(c)) + actions = append(actions, action.ActionJarFileClasses(file)) } } - return actions.ToMultiPartsA(".") + return carapace.Batch(actions...).Invoke(c).Merge().ToMultiPartsA(".") }) } diff --git a/completers/kill_completer/cmd/root.go b/completers/kill_completer/cmd/root.go index c85ecb07fe..d2c3049fef 100644 --- a/completers/kill_completer/cmd/root.go +++ b/completers/kill_completer/cmd/root.go @@ -54,8 +54,9 @@ func init() { func actionProcessIdsAndNames() carapace.Action { return carapace.ActionCallback(func(c carapace.Context) carapace.Action { - pids := os.ActionProcessIds().Invoke(c) - names := os.ActionProcessExecutables().Invoke(c) - return pids.Merge(names).Filter(c.Args).ToA() + return carapace.Batch( + os.ActionProcessIds(), + os.ActionProcessExecutables(), + ).Invoke(c).Merge().Filter(c.Args).ToA() }) } diff --git a/completers/pandoc_completer/cmd/action/format.go b/completers/pandoc_completer/cmd/action/format.go index c0b751bef7..1d0e5be5a4 100644 --- a/completers/pandoc_completer/cmd/action/format.go +++ b/completers/pandoc_completer/cmd/action/format.go @@ -53,9 +53,10 @@ func extensionFields(s string) []string { func ActionFormats() carapace.Action { return carapace.ActionCallback(func(c carapace.Context) carapace.Action { - input := ActionInputFormats().Invoke(c) - output := ActionOutputFormats().Invoke(c) - return input.Merge(output).ToA() + return carapace.Batch( + ActionInputFormats(), + ActionOutputFormats(), + ).Invoke(c).Merge().ToA() }) } diff --git a/go.mod b/go.mod index 739aace1e4..feab13bd7e 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/mitchellh/go-homedir v1.1.0 github.com/mitchellh/go-ps v1.0.0 github.com/pelletier/go-toml v1.8.1 - github.com/rsteube/carapace v0.7.1 + github.com/rsteube/carapace v0.8.0 github.com/spf13/cobra v1.1.1 github.com/spf13/pflag v1.0.5 golang.org/x/sys v0.0.0-20210426230700-d19ff857e887 diff --git a/go.sum b/go.sum index 8f9354ab27..2b43cf4e16 100644 --- a/go.sum +++ b/go.sum @@ -148,8 +148,8 @@ github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7z github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rsteube/carapace v0.7.1 h1:HfD0MgX8HtrhEqfodE+XAWogAF35UdisWxDiblLi7bA= -github.com/rsteube/carapace v0.7.1/go.mod h1:Vo7qSmFjuOTjB3cEyyat0+ANvVHlS0HR4NhIdAN07vM= +github.com/rsteube/carapace v0.8.0 h1:OVTWIqLmE9qskAtFOIvYvDNmB+6fL3Ovxe5y78iBXQ8= +github.com/rsteube/carapace v0.8.0/go.mod h1:Vo7qSmFjuOTjB3cEyyat0+ANvVHlS0HR4NhIdAN07vM= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=