cmd/loop: add amount as a discrete argument

pull/26/head
Alex Bosworth 5 years ago
parent 769c69e512
commit dd357ddb22
No known key found for this signature in database
GPG Key ID: E80D2F3F311FD87E

@ -31,24 +31,34 @@ var loopOutCommand = cli.Command{
"should be sent to, if let blank the funds " + "should be sent to, if let blank the funds " +
"will go to lnd's wallet", "will go to lnd's wallet",
}, },
cli.Uint64Flag{
Name: "amt",
Usage: "the amount in satoshis to loop out",
},
}, },
Action: loopOut, Action: loopOut,
} }
func loopOut(ctx *cli.Context) error { func loopOut(ctx *cli.Context) error {
// Show command help if no arguments and flags were provided. args := ctx.Args()
if ctx.NArg() < 1 {
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") cli.ShowCommandHelp(ctx, "out")
return nil return nil
} }
args := ctx.Args() amt, err := parseAmt(amtStr)
amt, err := parseAmt(args[0])
if err != nil { if err != nil {
return err return err
} }
args = args.Tail()
var destAddr string var destAddr string
switch { switch {

Loading…
Cancel
Save