bash_completions: Generic function for --filename arguments

This generic function adds --filename= arguments to commands, and does
the magic so they get bash completions to find json, yaml, or yml files.
This commit is contained in:
Eric Paris
2015-03-28 23:38:46 -04:00
parent 037407f49e
commit de3864a1c2
6 changed files with 70 additions and 4 deletions

View File

@@ -22,6 +22,7 @@ import (
"github.com/spf13/cobra"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl"
cmdutil "github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl/cmd/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl/resource"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
@@ -50,7 +51,10 @@ func NewCmdCreate(f *cmdutil.Factory, out io.Writer) *cobra.Command {
cmdutil.CheckErr(RunCreate(f, out, filenames))
},
}
cmd.Flags().VarP(&filenames, "filename", "f", "Filename, directory, or URL to file to use to create the resource")
usage := "Filename, directory, or URL to file to use to create the resource"
kubectl.AddJsonFilenameFlag(cmd, &filenames, usage)
return cmd
}