Skip to content

Commit

Permalink
cli: set --port flag on client commands.
Browse files Browse the repository at this point in the history
For some reason, we had split up `--port` between `simpleCmds` and
`sqlCmds`. These are all `clientCmds`
  • Loading branch information
marc committed Mar 17, 2017
1 parent 150b52d commit 4829b13
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions pkg/cli/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,18 +343,23 @@ func init() {
boolFlag(setUserCmd.Flags(), &password, cliflags.Password, false)

clientCmds := []*cobra.Command{
sqlShellCmd, quitCmd, freezeClusterCmd, dumpCmd, /* startCmd is covered above */
debugZipCmd,
dumpCmd,
freezeClusterCmd,
genHAProxyCmd,
quitCmd,
sqlShellCmd,
/* startCmd is covered above */
}
clientCmds = append(clientCmds, kvCmds...)
clientCmds = append(clientCmds, rangeCmds...)
clientCmds = append(clientCmds, userCmds...)
clientCmds = append(clientCmds, zoneCmds...)
clientCmds = append(clientCmds, nodeCmds...)
clientCmds = append(clientCmds, debugZipCmd)
clientCmds = append(clientCmds, genHAProxyCmd)
for _, cmd := range clientCmds {
f := cmd.PersistentFlags()
stringFlag(f, &connHost, cliflags.ClientHost, "")
stringFlag(f, &connPort, cliflags.ClientPort, base.DefaultPort)

varFlag(f, insecure, cliflags.Insecure)
// Allow '--insecure'
Expand All @@ -376,18 +381,6 @@ func init() {

boolFlag(freezeClusterCmd.PersistentFlags(), &undoFreezeCluster, cliflags.UndoFreezeCluster, false)

// Commands that need the cockroach port.
simpleCmds := []*cobra.Command{quitCmd, freezeClusterCmd}
simpleCmds = append(simpleCmds, kvCmds...)
simpleCmds = append(simpleCmds, rangeCmds...)
simpleCmds = append(simpleCmds, nodeCmds...)
simpleCmds = append(simpleCmds, debugZipCmd)
simpleCmds = append(simpleCmds, genHAProxyCmd)
for _, cmd := range simpleCmds {
f := cmd.PersistentFlags()
stringFlag(f, &connPort, cliflags.ClientPort, base.DefaultPort)
}

// Commands that establish a SQL connection.
sqlCmds := []*cobra.Command{sqlShellCmd, dumpCmd}
sqlCmds = append(sqlCmds, zoneCmds...)
Expand All @@ -397,7 +390,6 @@ func init() {
stringFlag(f, &connURL, cliflags.URL, "")

stringFlag(f, &connUser, cliflags.User, security.RootUser)
stringFlag(f, &connPort, cliflags.ClientPort, base.DefaultPort)
stringFlag(f, &connDBName, cliflags.Database, "")
}

Expand Down

0 comments on commit 4829b13

Please sign in to comment.