From 04a2f66d6493ae84d7967e3293220277cb3f6f28 Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Tue, 19 Nov 2013 13:44:52 -0600 Subject: [PATCH] Allow go-flags to generate help entry in btcctl. --- util/btcctl/btcctl.go | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/util/btcctl/btcctl.go b/util/btcctl/btcctl.go index 6276a802..399abb41 100644 --- a/util/btcctl/btcctl.go +++ b/util/btcctl/btcctl.go @@ -14,12 +14,11 @@ import ( ) type config struct { - Help bool `short:"h" long:"help" description:"Help"` - RpcUser string `short:"u" long:"rpcuser" description:"RPC username"` - RpcPassword string `short:"P" long:"rpcpass" description:"RPC password"` - RpcServer string `short:"s" long:"rpcserver" description:"RPC server to connect to"` - RpcCert string `short:"c" long:"rpccert" description:"RPC server certificate chain for validation"` - TlsSkipVerify bool `long:"skipverify" description:"Do not verify tls certificates (not recommended!)"` + RpcUser string `short:"u" long:"rpcuser" description:"RPC username"` + RpcPassword string `short:"P" long:"rpcpass" description:"RPC password"` + RpcServer string `short:"s" long:"rpcserver" description:"RPC server to connect to"` + RpcCert string `short:"c" long:"rpccert" description:"RPC server certificate chain for validation"` + TlsSkipVerify bool `long:"skipverify" description:"Do not verify tls certificates (not recommended!)"` } // conversionHandler is a handler that is used to convert parameters from the @@ -372,15 +371,13 @@ func main() { cfg := config{ RpcServer: "127.0.0.1:8334", } - parser := flags.NewParser(&cfg, flags.PassDoubleDash) + parser := flags.NewParser(&cfg, flags.PassDoubleDash|flags.HelpFlag) args, err := parser.Parse() if err != nil { - if e, ok := err.(*flags.Error); !ok || e.Type != flags.ErrHelp { - usage(parser) - } + usage(parser) os.Exit(1) } - if len(args) < 1 || cfg.Help { + if len(args) < 1 { usage(parser) return }