Skip to content

Commit

Permalink
Revert "[cmd/*] Switch to pflag for all CLI flag parsing (vitessio#10619
Browse files Browse the repository at this point in the history
)"

This reverts commit c3f4a99.

Signed-off-by: Dirkjan Bussink <[email protected]>
  • Loading branch information
dbussink committed Jul 26, 2022
1 parent 0065ae1 commit 5363673
Show file tree
Hide file tree
Showing 27 changed files with 1,486 additions and 872 deletions.
4 changes: 1 addition & 3 deletions go/cmd/mysqlctl/mysqlctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ import (
"os"
"time"

"github.com/spf13/pflag"

"vitess.io/vitess/go/cmd"
"vitess.io/vitess/go/exit"
"vitess.io/vitess/go/flagutil"
Expand Down Expand Up @@ -250,7 +248,7 @@ func main() {
exit.Return(1)
}
dbconfigs.RegisterFlags(dbconfigs.Dba)
_flag.Parse(pflag.NewFlagSet("mysqlctl", pflag.ExitOnError))
_flag.Parse()

tabletAddr = netutil.JoinHostPort("localhost", int32(*port))

Expand Down
4 changes: 1 addition & 3 deletions go/cmd/query_analyzer/query_analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ import (
"os"
"sort"

"github.com/spf13/pflag"

"vitess.io/vitess/go/exit"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/sqlparser"
Expand Down Expand Up @@ -61,7 +59,7 @@ func (a stats) Less(i, j int) bool { return a[i].Count > a[j].Count }

func main() {
defer exit.Recover()
_flag.Parse(pflag.NewFlagSet("query_analyzer", pflag.ExitOnError))
_flag.Parse()
for _, filename := range _flag.Args() {
fmt.Printf("processing: %s\n", filename)
if err := processFile(filename); err != nil {
Expand Down
4 changes: 1 addition & 3 deletions go/cmd/topo2topo/topo2topo.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import (
"fmt"
"os"

"github.com/spf13/pflag"

"vitess.io/vitess/go/exit"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/logutil"
Expand Down Expand Up @@ -55,7 +53,7 @@ func main() {
defer exit.RecoverAll()
defer logutil.Flush()

_flag.Parse(pflag.NewFlagSet("topo2topo", pflag.ExitOnError))
_flag.Parse()
args := _flag.Args()
if len(args) != 0 {
flag.Usage()
Expand Down
4 changes: 1 addition & 3 deletions go/cmd/vtbench/vtbench.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import (
"strings"
"time"

"github.com/spf13/pflag"

"vitess.io/vitess/go/exit"
"vitess.io/vitess/go/vt/dbconfigs"
"vitess.io/vitess/go/vt/log"
Expand Down Expand Up @@ -106,7 +104,7 @@ func main() {
defer exit.Recover()

flag.Lookup("logtostderr").Value.Set("true")
_flag.Parse(pflag.NewFlagSet("vtbench", pflag.ExitOnError))
_flag.Parse()

clientProto := vtbench.MySQL
switch *protocol {
Expand Down
3 changes: 1 addition & 2 deletions go/cmd/vtclient/vtclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
"time"

"github.com/olekukonko/tablewriter"
"github.com/spf13/pflag"

"vitess.io/vitess/go/vt/concurrency"
"vitess.io/vitess/go/vt/log"
Expand Down Expand Up @@ -148,7 +147,7 @@ func main() {
}

func run() (*results, error) {
_flag.Parse(pflag.NewFlagSet("vtclient", pflag.ExitOnError))
_flag.Parse()
args := _flag.Args()

if len(args) == 0 {
Expand Down
4 changes: 1 addition & 3 deletions go/cmd/vtctlclient/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ import (
"strings"
"time"

"github.com/spf13/pflag"

"vitess.io/vitess/go/exit"
"vitess.io/vitess/go/trace"
"vitess.io/vitess/go/vt/log"
Expand Down Expand Up @@ -72,7 +70,7 @@ func checkDeprecations(args []string) {
func main() {
defer exit.Recover()

_flag.Parse(pflag.NewFlagSet("vtctlclient", pflag.ExitOnError))
_flag.Parse()

closer := trace.StartTracing("vtctlclient")
defer trace.LogErrorsWhenClosing(closer)
Expand Down
2 changes: 1 addition & 1 deletion go/cmd/vtgate/vtgate.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func main() {
log.Exitf("tablet_types_to_wait should contain at least one serving tablet type")
}

err := CheckCellFlags(context.Background(), resilientServer, *cell, vtgate.CellsToWatch)
err := CheckCellFlags(context.Background(), resilientServer, *cell, *vtgate.CellsToWatch)
if err != nil {
log.Exitf("cells_to_watch validation failed: %v", err)
}
Expand Down
4 changes: 1 addition & 3 deletions go/cmd/vtgr/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import (
"flag"
"strings"

"github.com/spf13/pflag"

"vitess.io/vitess/go/vt/vtgr"

// Include deprecation warnings for soon-to-be-unsupported flag invocations.
Expand All @@ -28,7 +26,7 @@ import (

func main() {
clustersToWatch := flag.String("clusters_to_watch", "", "Comma-separated list of keyspaces or keyspace/shards that this instance will monitor and repair. Defaults to all clusters in the topology. Example: \"ks1,ks2/-80\"")
_flag.Parse(pflag.NewFlagSet("vtgr", pflag.ExitOnError))
_flag.Parse()

// openTabletDiscovery will open up a connection to topo server
// and populate the tablets in memory
Expand Down
4 changes: 1 addition & 3 deletions go/cmd/vttlstest/vttlstest.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ import (
"fmt"
"io"

"github.com/spf13/pflag"

"vitess.io/vitess/go/exit"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/logutil"
Expand Down Expand Up @@ -139,7 +137,7 @@ func main() {
_flag.SetUsage(flag.CommandLine, _flag.UsageOptions{
Preface: func(w io.Writer) { fmt.Fprint(w, doc) },
})
_flag.Parse(pflag.NewFlagSet("vttlstest", pflag.ExitOnError))
_flag.Parse()
args := _flag.Args()
if len(args) == 0 {
flag.Usage()
Expand Down
6 changes: 2 additions & 4 deletions go/cmd/zk/zkcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import (
"syscall"
"time"

"github.com/spf13/pflag"
"github.com/z-division/go-zookeeper/zk"
"golang.org/x/term"

Expand Down Expand Up @@ -141,11 +140,10 @@ func main() {
defer exit.Recover()
defer logutil.Flush()

fs := pflag.NewFlagSet("zkcmd", pflag.ExitOnError)
_flag.SetUsage(flag.CommandLine, _flag.UsageOptions{ // TODO: hmmm
_flag.SetUsage(flag.CommandLine, _flag.UsageOptions{
Epilogue: func(w io.Writer) { fmt.Fprint(w, doc) },
})
_flag.Parse(fs)
_flag.Parse()
args := _flag.Args()
if len(args) == 0 {
flag.Usage()
Expand Down
4 changes: 1 addition & 3 deletions go/cmd/zkctl/zkctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ import (
"io"
"os"

"github.com/spf13/pflag"

"vitess.io/vitess/go/exit"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/logutil"
Expand Down Expand Up @@ -62,7 +60,7 @@ func main() {
defer exit.Recover()
defer logutil.Flush()

_flag.Parse(pflag.NewFlagSet("zkctl", pflag.ExitOnError))
_flag.Parse()
args := _flag.Args()

if len(args) == 0 {
Expand Down
4 changes: 1 addition & 3 deletions go/cmd/zkctld/zkctld.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ import (
"os/signal"
"syscall"

"github.com/spf13/pflag"

"vitess.io/vitess/go/exit"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/logutil"
Expand All @@ -47,7 +45,7 @@ func main() {
defer exit.Recover()
defer logutil.Flush()

_flag.Parse(pflag.NewFlagSet("zkctld", pflag.ExitOnError))
_flag.Parse()

zkConfig := zkctl.MakeZkConfigFromString(*zkCfg, uint32(*myID))
zkd := zkctl.NewZkd(zkConfig)
Expand Down
Loading

0 comments on commit 5363673

Please sign in to comment.