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

feat(mk_command): read from stdin or arg #91

Merged
merged 1 commit into from
Jul 8, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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