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

@@ -20,6 +20,7 @@ import (
"fmt"
"io"
"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"
@@ -79,7 +80,8 @@ func NewCmdStop(f *cmdutil.Factory, out io.Writer) *cobra.Command {
})
},
}
cmd.Flags().VarP(&flags.Filenames, "filename", "f", "Filename, directory, or URL to file of resource(s) to be stopped")
usage := "Filename, directory, or URL to file of resource(s) to be stopped"
kubectl.AddJsonFilenameFlag(cmd, &flags.Filenames, usage)
cmd.Flags().StringP("selector", "l", "", "Selector (label query) to filter on")
cmd.Flags().Bool("all", false, "[-all] to select all the specified resources")
return cmd