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

Commit

Permalink
feat(etcdctl): obey the -C flag
Browse files Browse the repository at this point in the history
take a comma seperated list of nodes in the -C flag and use them in the
etcd client.
  • Loading branch information
Brandon Philips committed Oct 10, 2013
1 parent a12bd57 commit 0c37fcc
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
7 changes: 5 additions & 2 deletions etcdctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ import (
)

var (
cluster = flag.String("C", "0.0.0.0:4001", "a list of machine addresses in the cluster")
client = etcd.NewClient()
client *etcd.Client
)

func main() {
cluster := ClusterValue{"http://localhost:4001"}
flag.Var(&cluster, "C", "a comma seperated list of machine addresses in the cluster e.g. 127.0.0.1:4001,127.0.0.1:4002")
flag.Parse()

client = etcd.NewClient(cluster.GetMachines())

args := flag.Args()

if len(args) == 0 {
Expand Down
27 changes: 27 additions & 0 deletions flags.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package main

import (
"strings"
)

type ClusterValue struct {
machines string
}

func (c *ClusterValue) String() string {
return c.machines
}

func (c *ClusterValue) Set(value string) error {
if len(value) == 0 {
return nil
}

c.machines = value

return nil
}

func (c *ClusterValue) GetMachines() []string {
return strings.Split(c.machines, ",")
}

0 comments on commit 0c37fcc

Please sign in to comment.