carapace-sh / carapace

command argument completion generator for spf13/cobra
https://carapace.sh
Apache License 2.0
290 stars 8 forks source link

DisableFlagParsing: positional completion is repeated #962

Closed rsteube closed 7 months ago

rsteube commented 7 months ago

Current Behavior

Positional completion gets repeated when flag parsing is disabled:

example disabled p1 p2 po<TAB>
# positional1

Expected Behavior

Nothing should be completed on the third position.

Steps To Reproduce

No response

Version

0.47.2

OS

Shell

Anything else?

package cmd

import (
    "github.com/rsteube/carapace"
    "github.com/spf13/cobra"
)

var disabledCmd = &cobra.Command{
    Use:                "disabled",
    Short:              "",
    DisableFlagParsing: true,
    Run:                func(cmd *cobra.Command, args []string) {},
}

func init() {
    carapace.Gen(disabledCmd).Standalone()

    rootCmd.AddCommand(disabledCmd)

    carapace.Gen(disabledCmd).PositionalCompletion(
        carapace.ActionValues("p1", "positional1"),
        carapace.ActionValues("p2", "positional2"),
    )
}