diff --git a/completers/minikube_completer/cmd/image_load.go b/completers/minikube_completer/cmd/image_load.go index 8d9f711ba5..9f562ea303 100644 --- a/completers/minikube_completer/cmd/image_load.go +++ b/completers/minikube_completer/cmd/image_load.go @@ -3,7 +3,7 @@ package cmd import ( "github.com/rsteube/carapace" "github.com/rsteube/carapace-bin/pkg/actions/tools/docker" - "github.com/rsteube/carapace/pkg/util" + "github.com/rsteube/carapace/pkg/condition" "github.com/spf13/cobra" ) @@ -22,11 +22,9 @@ func init() { imageCmd.AddCommand(image_loadCmd) carapace.Gen(image_loadCmd).PositionalCompletion( - carapace.ActionCallback(func(c carapace.Context) carapace.Action { - if util.HasPathPrefix(c.Value) { - return carapace.ActionFiles() - } - return docker.ActionRepositoryTags() - }), + carapace.Batch( + carapace.ActionFiles(), + docker.ActionRepositoryTags().Unless(condition.CompletingPath), + ).ToA(), ) } diff --git a/completers/minikube_completer/cmd/start.go b/completers/minikube_completer/cmd/start.go index 9e5b51695a..17bad2d428 100644 --- a/completers/minikube_completer/cmd/start.go +++ b/completers/minikube_completer/cmd/start.go @@ -5,7 +5,6 @@ import ( "github.com/rsteube/carapace-bin/completers/minikube_completer/cmd/action" "github.com/rsteube/carapace-bin/pkg/actions/os" "github.com/rsteube/carapace-bin/pkg/actions/tools/docker" - "github.com/rsteube/carapace/pkg/util" "github.com/spf13/cobra" ) @@ -100,22 +99,18 @@ func init() { carapace.Gen(startCmd).FlagCompletion(carapace.ActionMap{ "addons": action.ActionAddons().UniqueList(","), "base-image": docker.ActionRepositoryTags(), - "cni": carapace.ActionCallback(func(c carapace.Context) carapace.Action { - if util.HasPathPrefix(c.Value) { - return carapace.ActionFiles() - } - return carapace.ActionValues("auto", "bridge", "calico", "cilium", "flannel", "kindnet") - }), + "cni": carapace.Batch( + carapace.ActionFiles(), + carapace.ActionValues("auto", "bridge", "calico", "cilium", "flannel", "kindnet"), + ).ToA(), "container-runtime": carapace.ActionValues("docker", "cri-o", "containerd"), "cri-socket": carapace.ActionFiles(), "driver": carapace.ActionValues("virtualbox", "vmwarefusion", "kvm2", "vmware", "none", "docker", "podman", "ssh", "auto-detect"), "host-only-nic-type": carapace.ActionValues("Am79C970A", "Am79C973", "82540EM", "82543GC", "82545EM", "virtio"), - "hyperkit-vpnkit-sock": carapace.ActionCallback(func(c carapace.Context) carapace.Action { - if util.HasPathPrefix(c.Value) { - return carapace.ActionFiles() - } - return carapace.ActionValues("auto") - }), + "hyperkit-vpnkit-sock": carapace.Batch( + carapace.ActionFiles(), + carapace.ActionValues("auto"), + ).ToA(), "image-mirror-country": os.ActionLanguages(), // TODO country codes the same? "mount-string": carapace.ActionMultiParts(":", func(c carapace.Context) carapace.Action { switch len(c.Parts) {