Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

FlagCompletion

FlagCompletion defines completion for flags.

carapace.Gen(myCmd).FlagCompletion(carapace.ActionMap{
    "flagName": carapace.ActionValues("a", "b", "c"),
})

Optional argument

To mark a flag argument as optional (--name=value) the NoOptDefVal needs to be set to anything other than empty string.

rootCmd.Flag("optarg").NoOptDefVal = " "