warn if kubectl create with extra argument

This commit is contained in:
Lion-Wei 2017-12-04 17:17:54 +08:00
parent 0d22ddc802
commit d51fbd35ce

View File

@ -278,8 +278,8 @@ func createAndRefresh(info *resource.Info) error {
// NameFromCommandArgs is a utility function for commands that assume the first argument is a resource name
func NameFromCommandArgs(cmd *cobra.Command, args []string) (string, error) {
if len(args) == 0 {
return "", cmdutil.UsageErrorf(cmd, "NAME is required")
if len(args) != 1 {
return "", cmdutil.UsageErrorf(cmd, "exactly one NAME is required, got %d", len(args))
}
return args[0], nil
}