Merge pull request #2005 from pwittrock/complete

completion should suggest directories if use contains DIR
This commit is contained in:
Kubernetes Prow Robot
2019-12-21 16:21:32 -08:00
committed by GitHub
2 changed files with 5 additions and 1 deletions

View File

@@ -52,6 +52,10 @@ func Complete(cmd *cobra.Command) *complete.Command {
Flags: map[string]complete.Predictor{},
Sub: map[string]*complete.Command{},
}
if strings.Contains(cmd.Use, "DIR") {
// if usage contains directory, then use a file predictor
cc.Args = predict.Dirs("*")
}
// add completion for each subcommand
for i := range cmd.Commands() {

View File

@@ -14,7 +14,7 @@ import (
func GetFmtRunner(name string) *FmtRunner {
r := &FmtRunner{}
c := &cobra.Command{
Use: "fmt",
Use: "fmt DIR...",
Short: commands.FmtShort,
Long: commands.FmtLong,
Example: commands.FmtExamples,