Simple check to differentiate between stdin flag or value that contains

a -
This commit is contained in:
mckennajones 2016-11-27 12:55:14 -08:00
parent 2319624f69
commit 3b582db61d
1 changed files with 6 additions and 2 deletions

View File

@ -229,8 +229,12 @@ func (c *KVPutCommand) dataFromArgs(args []string) (string, string, error) {
return key, string(data), nil
case '-':
var b bytes.Buffer
if _, err := io.Copy(&b, stdin); err != nil {
return "", "", fmt.Errorf("Failed to read stdin: %s", err)
if len(data) > 1 {
return key, data, nil
} else {
if _, err := io.Copy(&b, stdin); err != nil {
return "", "", fmt.Errorf("Failed to read stdin: %s", err)
}
}
return key, b.String(), nil
default: