| 123456789101112131415161718192021222324252627282930313233 |
- package command
- import (
- "errors"
- "github.com/coreos/etcd/Godeps/_workspace/src/github.com/codegangsta/cli"
- "github.com/coreos/etcd/Godeps/_workspace/src/github.com/coreos/go-etcd/etcd"
- )
- // NewSetDirCommand returns the CLI command for "setDir".
- func NewSetDirCommand() cli.Command {
- return cli.Command{
- Name: "setdir",
- Usage: "create a new or existing directory",
- Flags: []cli.Flag{
- cli.IntFlag{"ttl", 0, "key time-to-live"},
- },
- Action: func(c *cli.Context) {
- handleDir(c, setDirCommandFunc)
- },
- }
- }
- // setDirCommandFunc executes the "setDir" command.
- func setDirCommandFunc(c *cli.Context, client *etcd.Client) (*etcd.Response, error) {
- if len(c.Args()) == 0 {
- return nil, errors.New("Key required")
- }
- key := c.Args()[0]
- ttl := c.Int("ttl")
- return client.SetDir(key, uint64(ttl))
- }
|