Allow go-flags to generate help entry in btcctl.
This commit is contained in:
parent
c3fab78e2c
commit
04a2f66d64
1 changed files with 8 additions and 11 deletions
|
@ -14,12 +14,11 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type config struct {
|
type config struct {
|
||||||
Help bool `short:"h" long:"help" description:"Help"`
|
RpcUser string `short:"u" long:"rpcuser" description:"RPC username"`
|
||||||
RpcUser string `short:"u" long:"rpcuser" description:"RPC username"`
|
RpcPassword string `short:"P" long:"rpcpass" description:"RPC password"`
|
||||||
RpcPassword string `short:"P" long:"rpcpass" description:"RPC password"`
|
RpcServer string `short:"s" long:"rpcserver" description:"RPC server to connect to"`
|
||||||
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"`
|
||||||
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!)"`
|
||||||
TlsSkipVerify bool `long:"skipverify" description:"Do not verify tls certificates (not recommended!)"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// conversionHandler is a handler that is used to convert parameters from the
|
// conversionHandler is a handler that is used to convert parameters from the
|
||||||
|
@ -372,15 +371,13 @@ func main() {
|
||||||
cfg := config{
|
cfg := config{
|
||||||
RpcServer: "127.0.0.1:8334",
|
RpcServer: "127.0.0.1:8334",
|
||||||
}
|
}
|
||||||
parser := flags.NewParser(&cfg, flags.PassDoubleDash)
|
parser := flags.NewParser(&cfg, flags.PassDoubleDash|flags.HelpFlag)
|
||||||
args, err := parser.Parse()
|
args, err := parser.Parse()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if e, ok := err.(*flags.Error); !ok || e.Type != flags.ErrHelp {
|
usage(parser)
|
||||||
usage(parser)
|
|
||||||
}
|
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
if len(args) < 1 || cfg.Help {
|
if len(args) < 1 {
|
||||||
usage(parser)
|
usage(parser)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue