Skip to content

Commit 023ac00

Browse files
committed
cmd/loop: crash if unknown flags are provided
Verify the number of positional arguments if they were provided to crash in such scenarios: $ loop out 250000 --xxx $ loop in 250000 1000 These commands used to work ignoring the last argument.
1 parent bfe7991 commit 023ac00

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

cmd/loop/liquidity.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ var setLiquidityRuleCommand = cli.Command{
4646
Name: "setrule",
4747
Usage: "set liquidity manager rule for a channel/peer",
4848
Description: "Update or remove the liquidity rule for a channel/peer.",
49-
ArgsUsage: "{shortchanid | peerpubkey}",
49+
ArgsUsage: "{shortchanid | peerpubkey}",
5050
Flags: []cli.Flag{
5151
cli.StringFlag{
5252
Name: "type",

cmd/loop/loopin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func loopIn(ctx *cli.Context) error {
9595
switch {
9696
case ctx.IsSet("amt"):
9797
amtStr = ctx.String("amt")
98-
case ctx.NArg() > 0:
98+
case ctx.NArg() == 1:
9999
amtStr = args[0]
100100
default:
101101
// Show command help if no arguments and flags were provided.

cmd/loop/loopout.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func loopOut(ctx *cli.Context) error {
131131
switch {
132132
case ctx.IsSet("amt"):
133133
amtStr = ctx.String("amt")
134-
case ctx.NArg() > 0:
134+
case ctx.NArg() == 1 || ctx.NArg() == 2:
135135
amtStr = args[0]
136136
args = args.Tail()
137137
default:

0 commit comments

Comments
 (0)