From dd357ddb22a44a18eec96bba8b902bc286a56978 Mon Sep 17 00:00:00 2001 From: Alex Bosworth Date: Thu, 21 Mar 2019 22:02:08 -0700 Subject: [PATCH] cmd/loop: add amount as a discrete argument --- cmd/loop/loopout.go | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/cmd/loop/loopout.go b/cmd/loop/loopout.go index 0206463..f2390dc 100644 --- a/cmd/loop/loopout.go +++ b/cmd/loop/loopout.go @@ -31,24 +31,34 @@ 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 { + args := ctx.Args() + + var amtStr string + switch { + case ctx.IsSet("amt"): + amtStr = ctx.String("amt") + case ctx.NArg() > 0: + amtStr = args[0] + args = args.Tail() + default: + // Show command help if no arguments and flags were provided. cli.ShowCommandHelp(ctx, "out") return nil } - args := ctx.Args() - - amt, err := parseAmt(args[0]) + amt, err := parseAmt(amtStr) if err != nil { return err } - args = args.Tail() var destAddr string switch {