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

Fix pd-ctl help output #1763

Merged
merged 4 commits into from
Sep 18, 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
20 changes: 13 additions & 7 deletions tools/pd-ctl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,21 @@ var (
detach bool
interact bool
version bool
help bool
caPath string
certPath string
keyPath string
)

func init() {
flag.StringVarP(&url, "pd", "u", "http://127.0.0.1:2379", "The pd address")
flag.BoolVarP(&detach, "detach", "d", true, "Run pdctl without readline")
flag.BoolVarP(&interact, "interact", "i", false, "Run pdctl with readline")
flag.BoolVarP(&version, "version", "V", false, "print version information and exit")
flag.StringVar(&caPath, "cacert", "", "path of file that contains list of trusted SSL CAs.")
flag.StringVar(&certPath, "cert", "", "path of file that contains X509 certificate in PEM format.")
flag.StringVar(&keyPath, "key", "", "path of file that contains X509 key in PEM format.")
flag.StringVarP(&url, "pd", "u", "http://127.0.0.1:2379", "The pd address.")
flag.BoolVarP(&detach, "detach", "d", true, "Run pdctl without readline.")
flag.BoolVarP(&interact, "interact", "i", false, "Run pdctl with readline.")
flag.BoolVarP(&version, "version", "V", false, "Print version information and exit.")
flag.StringVar(&caPath, "cacert", "", "The path of file that contains list of trusted SSL CAs.")
flag.StringVar(&certPath, "cert", "", "The path of file that contains X509 certificate in PEM format.")
flag.StringVar(&keyPath, "key", "", "The path of file that contains X509 key in PEM format.")
flag.BoolVarP(&help, "help", "h", false, "Help message.")
}

func main() {
Expand All @@ -57,6 +59,10 @@ func main() {
flag.CommandLine.ParseErrorsWhitelist.UnknownFlags = true
flag.Parse()

if help {
flag.Usage()
os.Exit(0)
}
if version {
server.PrintPDInfo()
os.Exit(0)
Expand Down