Open engelkes-finstreet opened 6 years ago
Unfortunately, I can't reproduce this problem.
I tried replacing the contents of kotlin-argparser-example's Main.kt (except for imports and package statement) with your code, and it functioned correctly:
$ ./gradlew installDist
BUILD SUCCESSFUL in 0s
4 actionable tasks: 1 executed, 3 up-to-date
$ build/install/kotlin-argparser-example/bin/kotlin-argparser-example --help
usage: build/install/kotlin-argparser-example/bin/kotlin-argparser-example
[-h] [-t]
optional arguments:
-h, show this help message and exit
--help
-t, Test
--test
$ build/install/kotlin-argparser-example/bin/kotlin-argparser-example
Hello, false!
$ build/install/kotlin-argparser-example/bin/kotlin-argparser-example -t
Hello, true!
What do you mean by "In IntelliJ I set the program argument to i"? What is "i"?
Sorry for not being clear with IntelliJ. In IntelliJ you can set your run configuration and edit VM options and Program Arguments with which the application should start. Setting the Program Argument to -t gives the error described above.
Have you tried running it from the command line?
Currently I try to use kotlin-argparser in one of my projects. Unfortunately even a simple example throws an error.
class MyArgs(parser: ArgParser) { val test by parser.flagging("-t", "--test", help = "Test") }
fun main(args: Array<String>) = mainBody { ArgParser(args).parseInto(::MyArgs).run { println("Hello, ${test}!") } }
In IntelliJ I set the program argument to i but I get the error unrecognized option '-t' After debugging I found that in the method parseShortOpt the shortOptionDelegates only contains the help delegate.
Does anybody have a solution for this?