xenomachina / kotlin-argparser

Easy to use and concise yet powerful and robust command line argument parsing for Kotlin
GNU Lesser General Public License v2.1
485 stars 33 forks source link

Exception in thread "main" com.xenomachina.argparser.ShowHelpException: Help was requested #61

Closed sanity closed 6 years ago

sanity commented 6 years ago

Hi, any ideas about this exception? I thought it would print the help automatically (I passed --help as an arg).

Exception in thread "main" com.xenomachina.argparser.ShowHelpException: Help was requested
    at com.xenomachina.argparser.ArgParser$1.invoke(ArgParser.kt:608)
    at com.xenomachina.argparser.ArgParser$1.invoke(ArgParser.kt:38)
    at com.xenomachina.argparser.OptionDelegate.parseOption(OptionDelegate.kt:61)
    at com.xenomachina.argparser.ArgParser.parseLongOpt(ArgParser.kt:567)
    at com.xenomachina.argparser.ArgParser.access$parseLongOpt(ArgParser.kt:38)
    at com.xenomachina.argparser.ArgParser$parseOptions$2.invoke(ArgParser.kt:493)
    at com.xenomachina.argparser.ArgParser$parseOptions$2.invoke(ArgParser.kt:38)
    at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
    at com.xenomachina.argparser.ArgParser.getParseOptions(ArgParser.kt)
    at com.xenomachina.argparser.ArgParser.force(ArgParser.kt:448)
    at com.xenomachina.argparser.ArgParser.parseInto(ArgParser.kt:470)
...
JakeWharton commented 6 years ago

https://github.com/xenomachina/kotlin-argparser#error-handling

sanity commented 6 years ago

Ah, gotcha:

As a convenience, these exceptions can be handled by using the mainBody function:

If I can make a constructive suggestion, perhaps a bit more emphasis can be placed on this? It seems likely to be a very common use-case.

xenomachina commented 6 years ago

Yes, I agree that this could've been made a bit more obvious in the documentation.

I've tweaked the "Help Formatting" section of the README. Let me know if you think there's anything else that could be done to make this more clear.