Skip to content

Commit e14e7e9

Browse files
authored
Merge pull request #26 from alexbosworth/keyword-amt-argument
cmd/loop: add amount as a discrete argument
2 parents ba6994e + dd357dd commit e14e7e9

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

cmd/loop/loopout.go

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,24 +31,34 @@ var loopOutCommand = cli.Command{
3131
"should be sent to, if let blank the funds " +
3232
"will go to lnd's wallet",
3333
},
34+
cli.Uint64Flag{
35+
Name: "amt",
36+
Usage: "the amount in satoshis to loop out",
37+
},
3438
},
3539
Action: loopOut,
3640
}
3741

3842
func loopOut(ctx *cli.Context) error {
39-
// Show command help if no arguments and flags were provided.
40-
if ctx.NArg() < 1 {
43+
args := ctx.Args()
44+
45+
var amtStr string
46+
switch {
47+
case ctx.IsSet("amt"):
48+
amtStr = ctx.String("amt")
49+
case ctx.NArg() > 0:
50+
amtStr = args[0]
51+
args = args.Tail()
52+
default:
53+
// Show command help if no arguments and flags were provided.
4154
cli.ShowCommandHelp(ctx, "out")
4255
return nil
4356
}
4457

45-
args := ctx.Args()
46-
47-
amt, err := parseAmt(args[0])
58+
amt, err := parseAmt(amtStr)
4859
if err != nil {
4960
return err
5061
}
51-
args = args.Tail()
5262

5363
var destAddr string
5464
switch {

0 commit comments

Comments
 (0)