From e794a867060684fc2ddb7cc775837e96533d383a Mon Sep 17 00:00:00 2001 From: Alex Bosworth Date: Thu, 21 Mar 2019 09:26:34 -0700 Subject: [PATCH] cmd/loop: add new keyword argument for amt In this commit there is a new keyword argument for amt to add an alternative to the positional argument for amt --- cmd/loop/loopout.go | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/cmd/loop/loopout.go b/cmd/loop/loopout.go index 0206463..7e1423c 100644 --- a/cmd/loop/loopout.go +++ b/cmd/loop/loopout.go @@ -31,24 +31,33 @@ var loopOutCommand = cli.Command{ "should be sent to, if let blank the funds " + "will go to lnd's wallet", }, + cli.Uint64Flag{ + Name: "amt", + Usage: "the amount in satoshis to loop out", + }, }, Action: loopOut, } func loopOut(ctx *cli.Context) error { - // Show command help if no arguments and flags were provided. - if ctx.NArg() < 1 { - cli.ShowCommandHelp(ctx, "out") - return nil - } - args := ctx.Args() - amt, err := parseAmt(args[0]) + var amtStr string + if ctx.IsSet("amt") { + amtStr = ctx.String("amt") + } else if ctx.NArg() > 0 { + amtStr = args[0] + args = args.Tail() + } else { + // Show command help if no arguments and flags were provided. + cli.ShowCommandHelp(ctx, "out") + return nil + } + + amt, err := parseAmt(amtStr) if err != nil { return err } - args = args.Tail() var destAddr string switch {