Skip to content

Leftover args not parsed as expected #60

Closed
@zhranklin

Description

I'm using mainargs in ammonite, but the result is not correct.

code

run in ammonite 2.5.8/scala 3.2.1/java 17

// filename: bug.sc
import mainargs.Leftover
@main
def mycmd(@arg(name = "the-flag") f: mainargs.Flag = mainargs.Flag(false), @arg str: String = "s", args: Leftover[String]) = {
  println(f)
  println(str)
  println(args)
}

case 1

amm bug.sc --str str a b c d

expected:

Flag(false)
str
Leftover(List(a, b, c, d))

actual:

Flag(true)
str
Leftover(List(b, c, d))

case 2

amm bug.sc a b c d

expected:

 Flag(false)
 s
 Leftover(List(a, b, c, d))

actual:

 Flag(true)
 b
 Leftover(List(c, d))

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions