Skip to content

Commit

Permalink
binlogctl: refine log output when use help command (#580)
Browse files Browse the repository at this point in the history
  • Loading branch information
WangXiangUSTC authored May 6, 2019
1 parent 78f4d7f commit d0fe901
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions binlogctl/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"crypto/tls"
"flag"
"fmt"
"os"

"github.com/pingcap/errors"
"github.com/pingcap/tidb-binlog/pkg/flags"
Expand Down Expand Up @@ -99,9 +100,14 @@ func NewConfig() *Config {
func (cfg *Config) Parse(args []string) error {
// parse first to get config file
err := cfg.FlagSet.Parse(args)
if err != nil {
return errors.Trace(err)
switch err {
case nil:
case flag.ErrHelp:
os.Exit(0)
default:
os.Exit(2)
}

// parse command line options
if len(cfg.FlagSet.Args()) > 0 {
return errors.Errorf("'%s' is not a valid flag", cfg.FlagSet.Arg(0))
Expand Down

0 comments on commit d0fe901

Please sign in to comment.