Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions go/cmd/mysqlctl/mysqlctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@ package main
import (
"vitess.io/vitess/go/cmd/mysqlctl/command"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/utils"
)

func main() {
command.Root.SetGlobalNormalizationFunc(utils.NormalizeUnderscoresToDashes)

if err := command.Root.Execute(); err != nil {
log.Exit(err)
}
Expand Down
3 changes: 3 additions & 0 deletions go/cmd/mysqlctld/mysqlctld.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ package main
import (
"vitess.io/vitess/go/cmd/mysqlctld/cli"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/utils"
)

func main() {
cli.Main.SetGlobalNormalizationFunc(utils.NormalizeUnderscoresToDashes)

if err := cli.Main.Execute(); err != nil {
log.Exit(err)
}
Expand Down
2 changes: 2 additions & 0 deletions go/cmd/rulesctl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import (
vtlog "vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/logutil"
"vitess.io/vitess/go/vt/servenv"
"vitess.io/vitess/go/vt/utils"
)

func main() {
rootCmd := cmd.Main()
rootCmd.SetGlobalNormalizationFunc(utils.NormalizeUnderscoresToDashes)
vtlog.RegisterFlags(rootCmd.PersistentFlags())
logutil.RegisterFlags(rootCmd.PersistentFlags())
acl.RegisterFlags(rootCmd.PersistentFlags())
Expand Down
2 changes: 2 additions & 0 deletions go/cmd/topo2topo/topo2topo.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ import (
"vitess.io/vitess/go/cmd/topo2topo/cli"
"vitess.io/vitess/go/exit"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/utils"
)

func main() {
defer exit.RecoverAll()

cli.Main.SetGlobalNormalizationFunc(utils.NormalizeUnderscoresToDashes)
if err := cli.Main.Execute(); err != nil {
log.Exitf("%s", err)
}
Expand Down
3 changes: 3 additions & 0 deletions go/cmd/vtaclcheck/cli/vtactlcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"vitess.io/vitess/go/acl"
"vitess.io/vitess/go/vt/logutil"
"vitess.io/vitess/go/vt/servenv"
"vitess.io/vitess/go/vt/utils"
"vitess.io/vitess/go/vt/vtaclcheck"
)

Expand Down Expand Up @@ -58,6 +59,8 @@ func run(cmd *cobra.Command, args []string) error {
}

func init() {
Main.SetGlobalNormalizationFunc(utils.NormalizeUnderscoresToDashes)

servenv.MoveFlagsToCobraCommand(Main)

Main.Flags().StringVar(&aclFile, "acl-file", aclFile, "The path of the JSON ACL file to check")
Expand Down
1 change: 1 addition & 0 deletions go/cmd/vtadmin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ func registerFlags() {
func main() {
registerFlags()

rootCmd.SetGlobalNormalizationFunc(utils.NormalizeUnderscoresToDashes)
if err := rootCmd.Execute(); err != nil {
log.Fatal(err)
}
Expand Down
2 changes: 2 additions & 0 deletions go/cmd/vtbackup/vtbackup.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ import (
"vitess.io/vitess/go/cmd/vtbackup/cli"
"vitess.io/vitess/go/exit"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/utils"
)

func main() {
defer exit.Recover()

cli.Main.SetGlobalNormalizationFunc(utils.NormalizeUnderscoresToDashes)
if err := cli.Main.Execute(); err != nil {
log.Error(err)
exit.Return(1)
Expand Down
2 changes: 2 additions & 0 deletions go/cmd/vtbench/vtbench.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ import (
"vitess.io/vitess/go/cmd/vtbench/cli"
"vitess.io/vitess/go/exit"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/utils"
)

func main() {
defer exit.Recover()

cli.Main.SetGlobalNormalizationFunc(utils.NormalizeUnderscoresToDashes)
if err := cli.Main.Execute(); err != nil {
log.Exit(err)
}
Expand Down
3 changes: 3 additions & 0 deletions go/cmd/vtclient/vtclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ package main
import (
"vitess.io/vitess/go/cmd/vtclient/cli"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/utils"
)

func main() {
cli.InitializeFlags()

cli.Main.SetGlobalNormalizationFunc(utils.NormalizeUnderscoresToDashes)
if err := cli.Main.Execute(); err != nil {
log.Exit(err)
}
Expand Down
4 changes: 2 additions & 2 deletions go/cmd/vtcombo/cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ func run(cmd *cobra.Command, args []string) (err error) {

// vtctld UI requires the cell flag
cmd.Flags().Set("cell", tpb.Cells[0])
if f := cmd.Flags().Lookup("log_dir"); f != nil && !f.Changed {
cmd.Flags().Set("log_dir", "$VTDATAROOT/tmp")
if f := cmd.Flags().Lookup("log-dir"); f != nil && !f.Changed {
Comment thread
arthurschreiber marked this conversation as resolved.
Outdated
cmd.Flags().Set("log-dir", "$VTDATAROOT/tmp")
}

env, err = vtenv.New(vtenv.Options{
Expand Down
2 changes: 2 additions & 0 deletions go/cmd/vtcombo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ import (
"vitess.io/vitess/go/cmd/vtcombo/cli"
"vitess.io/vitess/go/exit"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/utils"
)

func main() {
defer exit.Recover()

cli.Main.SetGlobalNormalizationFunc(utils.NormalizeUnderscoresToDashes)
if err := cli.Main.Execute(); err != nil {
log.Error(err)
exit.Return(1)
Expand Down
2 changes: 2 additions & 0 deletions go/cmd/vtctl/vtctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ func init() {
fs.BoolVar(&detachedMode, "detach", detachedMode, "detached mode - run vtcl detached from the terminal")

acl.RegisterFlags(fs)

fs.SetNormalizeFunc(utils.NormalizeUnderscoresToDashes)
})
}

Expand Down
2 changes: 2 additions & 0 deletions go/cmd/vtctlclient/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ func init() {
fs.StringVar(&server, "server", server, "server to use for connection")

acl.RegisterFlags(fs)

fs.SetNormalizeFunc(utils.NormalizeUnderscoresToDashes)
})
}

Expand Down
2 changes: 2 additions & 0 deletions go/cmd/vtctld/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ package main
import (
"vitess.io/vitess/go/cmd/vtctld/cli"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/utils"
)

func main() {
cli.Main.SetGlobalNormalizationFunc(utils.NormalizeUnderscoresToDashes)
if err := cli.Main.Execute(); err != nil {
log.Fatal(err)
}
Expand Down
2 changes: 2 additions & 0 deletions go/cmd/vtctldclient/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"vitess.io/vitess/go/vt/vttablet/tmclient"

_flag "vitess.io/vitess/go/internal/flag"
flagUtils "vitess.io/vitess/go/vt/utils"
)

func main() {
Expand All @@ -55,6 +56,7 @@ func main() {
// hack to get rid of an "ERROR: logging before flag.Parse"
_flag.TrickGlog()

command.Root.SetGlobalNormalizationFunc(flagUtils.NormalizeUnderscoresToDashes)
// back to your regularly scheduled cobra programming
if err := command.Root.Execute(); err != nil {
log.Error(err)
Expand Down
2 changes: 2 additions & 0 deletions go/cmd/vtexplain/vtexplain.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ import (

"vitess.io/vitess/go/cmd/vtexplain/cli"
"vitess.io/vitess/go/exit"
"vitess.io/vitess/go/vt/utils"
)

func main() {
defer exit.RecoverAll()

cli.Main.SetGlobalNormalizationFunc(utils.NormalizeUnderscoresToDashes)
if err := cli.Main.Execute(); err != nil {
fmt.Printf("ERROR: %s\n", err)
exit.Return(1)
Expand Down
4 changes: 1 addition & 3 deletions go/cmd/vtgate/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,5 @@ func init() {
Main.Flags().StringVar(&plannerName, "planner-version", plannerName, "Sets the default planner to use when the session has not changed it. Valid values are: Gen4, Gen4Greedy, Gen4Left2Right")

// Support both variants until v25
// Main.MarkFlagRequired("tablet-types-to-wait")
Main.MarkFlagsOneRequired("tablet-types-to-wait", "tablet_types_to_wait")

Main.MarkFlagsOneRequired("tablet-types-to-wait")
}
2 changes: 2 additions & 0 deletions go/cmd/vtgate/vtgate.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ package main
import (
"vitess.io/vitess/go/cmd/vtgate/cli"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/utils"
)

func main() {
cli.Main.SetGlobalNormalizationFunc(utils.NormalizeUnderscoresToDashes)
if err := cli.Main.Execute(); err != nil {
log.Exit(err)
}
Expand Down
2 changes: 2 additions & 0 deletions go/cmd/vtgateclienttest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ import (
"vitess.io/vitess/go/cmd/vtgateclienttest/cli"
"vitess.io/vitess/go/exit"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/utils"
)

func main() {
defer exit.Recover()

cli.Main.SetGlobalNormalizationFunc(utils.NormalizeUnderscoresToDashes)
if err := cli.Main.Execute(); err != nil {
log.Exitf("%s", err)
}
Expand Down
2 changes: 2 additions & 0 deletions go/cmd/vtorc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ package main
import (
"vitess.io/vitess/go/cmd/vtorc/cli"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/utils"
)

// main is the application's entry point. It will spawn an HTTP interface.
func main() {
// TODO: viperutil.BindFlags()

cli.Main.SetGlobalNormalizationFunc(utils.NormalizeUnderscoresToDashes)
if err := cli.Main.Execute(); err != nil {
log.Exit(err)
}
Expand Down
2 changes: 2 additions & 0 deletions go/cmd/vttablet/vttablet.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ package main
import (
"vitess.io/vitess/go/cmd/vttablet/cli"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/utils"
)

func main() {
cli.Main.SetGlobalNormalizationFunc(utils.NormalizeUnderscoresToDashes)
if err := cli.Main.Execute(); err != nil {
log.Exit(err)
}
Expand Down
5 changes: 4 additions & 1 deletion go/cmd/vttestserver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ package main
import (
"vitess.io/vitess/go/cmd/vttestserver/cli"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/utils"
)

func main() {
if err := cli.New().Execute(); err != nil {
cmd := cli.New()
cmd.SetGlobalNormalizationFunc(utils.NormalizeUnderscoresToDashes)
if err := cmd.Execute(); err != nil {
log.Fatal(err)
}
}
2 changes: 2 additions & 0 deletions go/cmd/vttlstest/vttlstest.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ import (
"vitess.io/vitess/go/cmd/vttlstest/cli"
"vitess.io/vitess/go/exit"
"vitess.io/vitess/go/vt/logutil"
"vitess.io/vitess/go/vt/utils"
)

func main() {
defer exit.Recover()
defer logutil.Flush()

cli.Root.SetGlobalNormalizationFunc(utils.NormalizeUnderscoresToDashes)
cobra.CheckErr(cli.Root.Execute())
}
2 changes: 2 additions & 0 deletions go/cmd/zk/zkcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"vitess.io/vitess/go/cmd/zk/command"
"vitess.io/vitess/go/exit"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/utils"
)

func main() {
Expand All @@ -38,6 +39,7 @@ func main() {
cancel()
}()

command.Root.SetGlobalNormalizationFunc(utils.NormalizeUnderscoresToDashes)
// Run the command.
if err := command.Root.ExecuteContext(ctx); err != nil {
log.Error(err)
Expand Down
2 changes: 2 additions & 0 deletions go/cmd/zkctl/zkctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ import (
"vitess.io/vitess/go/cmd/zkctl/command"
"vitess.io/vitess/go/exit"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/utils"
)

func main() {
defer exit.Recover()

command.Root.SetGlobalNormalizationFunc(utils.NormalizeUnderscoresToDashes)
if err := command.Root.Execute(); err != nil {
log.Error(err)
exit.Return(1)
Expand Down
2 changes: 2 additions & 0 deletions go/cmd/zkctld/zkctld.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ import (
"vitess.io/vitess/go/cmd/zkctld/cli"
"vitess.io/vitess/go/exit"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/utils"
)

func main() {
defer exit.Recover()
cli.Main.SetGlobalNormalizationFunc(utils.NormalizeUnderscoresToDashes)
if err := cli.Main.Execute(); err != nil {
log.Error(err)
exit.Return(1)
Expand Down
4 changes: 2 additions & 2 deletions go/vt/servenv/servenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,10 +357,10 @@ func moveFlags(name string, fs *pflag.FlagSet) {
// glog flags, no better way to do this
_flag.PreventGlogVFlagFromClobberingVersionFlagShorthand(fs)
fs.AddGoFlag(flag.Lookup("logtostderr"))
fs.AddGoFlag(flag.Lookup("log_backtrace_at"))
Comment thread
arthurschreiber marked this conversation as resolved.
fs.AddGoFlag(flag.Lookup("log-backtrace-at"))
fs.AddGoFlag(flag.Lookup("alsologtostderr"))
fs.AddGoFlag(flag.Lookup("stderrthreshold"))
fs.AddGoFlag(flag.Lookup("log_dir"))
fs.AddGoFlag(flag.Lookup("log-dir"))
fs.AddGoFlag(flag.Lookup("vmodule"))

pflag.CommandLine = fs
Expand Down
Loading
Loading