vitess.io/vitess@v0.16.2/go/cmd/vtctldclient/main.go (about)

     1  /*
     2  Copyright 2020 The Vitess Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package main
    18  
    19  import (
    20  	"flag"
    21  
    22  	"vitess.io/vitess/go/acl"
    23  	"vitess.io/vitess/go/cmd/vtctldclient/command"
    24  	"vitess.io/vitess/go/exit"
    25  	"vitess.io/vitess/go/vt/grpcclient"
    26  	"vitess.io/vitess/go/vt/grpccommon"
    27  	"vitess.io/vitess/go/vt/log"
    28  	"vitess.io/vitess/go/vt/logutil"
    29  	"vitess.io/vitess/go/vt/servenv"
    30  	"vitess.io/vitess/go/vt/vtctl/grpcclientcommon"
    31  	"vitess.io/vitess/go/vt/vtctl/vtctlclient"
    32  
    33  	_flag "vitess.io/vitess/go/internal/flag"
    34  )
    35  
    36  func main() {
    37  	defer exit.Recover()
    38  
    39  	// Grab all those global flags across the codebase and shove 'em on in.
    40  	// (TODO|andrew) remove this line after the migration to pflag is complete.
    41  	command.Root.PersistentFlags().AddGoFlagSet(flag.CommandLine)
    42  	log.RegisterFlags(command.Root.PersistentFlags())
    43  	logutil.RegisterFlags(command.Root.PersistentFlags())
    44  	grpcclient.RegisterFlags(command.Root.PersistentFlags())
    45  	grpccommon.RegisterFlags(command.Root.PersistentFlags())
    46  	grpcclientcommon.RegisterFlags(command.Root.PersistentFlags())
    47  	servenv.RegisterMySQLServerFlags(command.Root.PersistentFlags())
    48  	vtctlclient.RegisterFlags(command.Root.PersistentFlags())
    49  	acl.RegisterFlags(command.Root.PersistentFlags())
    50  
    51  	// hack to get rid of an "ERROR: logging before flag.Parse"
    52  	_flag.TrickGlog()
    53  
    54  	// back to your regularly scheduled cobra programming
    55  	if err := command.Root.Execute(); err != nil {
    56  		log.Error(err)
    57  		exit.Return(1)
    58  	}
    59  }