From ab007bb918e22a8ffbddd0aaceec03ac235a2dc9 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Fri, 5 May 2017 15:54:25 -0700 Subject: [PATCH] cmd/lncli: add key word argument support for new disconnect cmd --- cmd/lncli/commands.go | 20 ++++++++++++++++---- cmd/lncli/main.go | 2 +- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/cmd/lncli/commands.go b/cmd/lncli/commands.go index 0e10fdb8..ca5c4d88 100644 --- a/cmd/lncli/commands.go +++ b/cmd/lncli/commands.go @@ -254,7 +254,14 @@ var disconnectCommand = cli.Command{ Name: "disconnect", Usage: "disconnect a remote lnd peer identified by public key", ArgsUsage: "", - Action: disconnectPeer, + Flags: []cli.Flag{ + cli.StringFlag{ + Name: "node_key", + Usage: "The hex-encoded compressed public key of the peer " + + "to disconnect from", + }, + }, + Action: disconnectPeer, } func disconnectPeer(ctx *cli.Context) error { @@ -262,9 +269,14 @@ func disconnectPeer(ctx *cli.Context) error { client, cleanUp := getClient(ctx) defer cleanUp() - pubKey := ctx.Args().First() - if pubKey == "" { - return fmt.Errorf("target address expected in format: ") + var pubKey string + switch { + case ctx.IsSet("node_key"): + pubKey = ctx.String("node_key") + case ctx.Args().Present(): + pubKey = ctx.Args().First() + default: + return fmt.Errorf("must specify target public key") } req := &lnrpc.DisconnectPeerRequest{ diff --git a/cmd/lncli/main.go b/cmd/lncli/main.go index 16177e32..5ad0dcdb 100644 --- a/cmd/lncli/main.go +++ b/cmd/lncli/main.go @@ -57,6 +57,7 @@ func main() { sendManyCommand, sendCoinsCommand, connectCommand, + disconnectCommand, openChannelCommand, closeChannelCommand, listPeersCommand, @@ -78,7 +79,6 @@ func main() { debugLevelCommand, decodePayReqComamnd, listChainTxnsCommand, - disconnectCommand, } if err := app.Run(os.Args); err != nil {