Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

binlogctl: refine log output when use help command #580

Merged
merged 2 commits into from
May 6, 2019
Merged
Changes from all 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
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)
suzaku marked this conversation as resolved.
Show resolved Hide resolved
}

// 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