Browse Source

Merge pull request #4456 from mitake/v3-put-0-args

etcdctlv3: handle a case of 0 arguments in put command
Anthony Romano 10 years ago
parent
commit
f368639f00
1 changed files with 4 additions and 0 deletions
  1. 4 0
      etcdctlv3/command/put_command.go

+ 4 - 0
etcdctlv3/command/put_command.go

@@ -55,6 +55,10 @@ will store the content of the file to <key>.
 
 
 // putCommandFunc executes the "put" command.
 // putCommandFunc executes the "put" command.
 func putCommandFunc(cmd *cobra.Command, args []string) {
 func putCommandFunc(cmd *cobra.Command, args []string) {
+	if len(args) == 0 {
+		ExitWithError(ExitBadArgs, fmt.Errorf("put command needs 1 argument and input from stdin or 2 arguments."))
+	}
+
 	key := []byte(args[0])
 	key := []byte(args[0])
 	value, err := argOrStdin(args, os.Stdin, 1)
 	value, err := argOrStdin(args, os.Stdin, 1)
 	if err != nil {
 	if err != nil {