Skip to content
This repository was archived by the owner on Jun 4, 2019. It is now read-only.

Commit 6dcd7c2

Browse files
committed
Merge pull request #91 from carmstrong/mk_from_file
feat(mk_command): read from stdin or arg
2 parents fb2731b + 518ff4e commit 6dcd7c2

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

command/mk_command.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package command
22

33
import (
44
"errors"
5+
"os"
56

67
"github.com/coreos/etcdctl/third_party/github.com/codegangsta/cli"
78
"github.com/coreos/etcdctl/third_party/github.com/coreos/go-etcd/etcd"
@@ -25,11 +26,13 @@ func NewMakeCommand() cli.Command {
2526
func makeCommandFunc(c *cli.Context, client *etcd.Client) (*etcd.Response, error) {
2627
if len(c.Args()) == 0 {
2728
return nil, errors.New("Key required")
28-
} else if len(c.Args()) == 1 {
29-
return nil, errors.New("Value required")
3029
}
3130
key := c.Args()[0]
32-
value := c.Args()[1]
31+
value, err := argOrStdin(c.Args(), os.Stdin, 1)
32+
if err != nil {
33+
return nil, errors.New("Value required")
34+
}
35+
3336
ttl := c.Int("ttl")
3437

3538
return client.Create(key, value, uint64(ttl))

0 commit comments

Comments
 (0)