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.
This commit is contained in:
Boris Nagaev 2025-04-04 17:45:12 -03:00
parent bfe7991c4e
commit 023ac009c0
No known key found for this signature in database
3 changed files with 3 additions and 3 deletions

View file

@ -46,7 +46,7 @@ var setLiquidityRuleCommand = cli.Command{
Name: "setrule",
Usage: "set liquidity manager rule for a channel/peer",
Description: "Update or remove the liquidity rule for a channel/peer.",
ArgsUsage: "{shortchanid | peerpubkey}",
ArgsUsage: "{shortchanid | peerpubkey}",
Flags: []cli.Flag{
cli.StringFlag{
Name: "type",

View file

@ -95,7 +95,7 @@ func loopIn(ctx *cli.Context) error {
switch {
case ctx.IsSet("amt"):
amtStr = ctx.String("amt")
case ctx.NArg() > 0:
case ctx.NArg() == 1:
amtStr = args[0]
default:
// Show command help if no arguments and flags were provided.

View file

@ -131,7 +131,7 @@ func loopOut(ctx *cli.Context) error {
switch {
case ctx.IsSet("amt"):
amtStr = ctx.String("amt")
case ctx.NArg() > 0:
case ctx.NArg() == 1 || ctx.NArg() == 2:
amtStr = args[0]
args = args.Tail()
default: