Browse Source

etcdctl: break out getPeersFlagValue

Brian Waldon 11 years ago
parent
commit
bc62b05c7f
1 changed files with 10 additions and 6 deletions
  1. 10 6
      etcdctl/command/handle.go

+ 10 - 6
etcdctl/command/handle.go

@@ -37,11 +37,7 @@ func createHttpPath(addr string) (string, error) {
 	return u.String(), nil
 }
 
-// rawhandle wraps the command function handlers and sets up the
-// environment but performs no output formatting.
-func rawhandle(c *cli.Context, fn handlerFunc) (*etcd.Response, error) {
-	sync := !c.GlobalBool("no-sync")
-
+func getPeersFlagValue(c *cli.Context) []string {
 	peerstr := c.GlobalString("peers")
 
 	// Use an environment variable if nothing was supplied on the
@@ -55,7 +51,15 @@ func rawhandle(c *cli.Context, fn handlerFunc) (*etcd.Response, error) {
 		peerstr = "127.0.0.1:4001"
 	}
 
-	peers := strings.Split(peerstr, ",")
+	return strings.Split(peerstr, ",")
+}
+
+// rawhandle wraps the command function handlers and sets up the
+// environment but performs no output formatting.
+func rawhandle(c *cli.Context, fn handlerFunc) (*etcd.Response, error) {
+	sync := !c.GlobalBool("no-sync")
+
+	peers := getPeersFlagValue(c)
 
 	// If no sync, create http path for each peer address
 	if !sync {