Allow go-flags to generate help entry in btcctl.

This commit is contained in:
Dave Collins 2013-11-19 13:44:52 -06:00
parent c3fab78e2c
commit 04a2f66d64

View file

@ -14,7 +14,6 @@ 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"`
@ -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)
}
os.Exit(1)
}
if len(args) < 1 || cfg.Help {
if len(args) < 1 {
usage(parser)
return
}