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,7 +14,6 @@ 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"`
|
||||||
|
@ -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…
Add table
Reference in a new issue