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

Commit

Permalink
Merge pull request #91 from carmstrong/mk_from_file
Browse files Browse the repository at this point in the history
feat(mk_command): read from stdin or arg
  • Loading branch information
philips committed Jul 8, 2014
2 parents fb2731b + 518ff4e commit 6dcd7c2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions command/mk_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package command

import (
"errors"
"os"

"github.com/coreos/etcdctl/third_party/github.com/codegangsta/cli"
"github.com/coreos/etcdctl/third_party/github.com/coreos/go-etcd/etcd"
Expand All @@ -25,11 +26,13 @@ func NewMakeCommand() cli.Command {
func makeCommandFunc(c *cli.Context, client *etcd.Client) (*etcd.Response, error) {
if len(c.Args()) == 0 {
return nil, errors.New("Key required")
} else if len(c.Args()) == 1 {
return nil, errors.New("Value required")
}
key := c.Args()[0]
value := c.Args()[1]
value, err := argOrStdin(c.Args(), os.Stdin, 1)
if err != nil {
return nil, errors.New("Value required")
}

ttl := c.Int("ttl")

return client.Create(key, value, uint64(ttl))
Expand Down

0 comments on commit 6dcd7c2

Please sign in to comment.