Announcing kotlin-argparser: command line argument parsing for Kotlin


#1

I started programming in Kotlin a few months ago. The two languages I used the most before were Python and Java. I love that Kotlin is more or less as concise as Python, but is even safer than Java and has roughly Java-equivalent performance.

I wanted to try playing around with Kotlin’s delegates, to see what they could do beyond the built-in ones (like lazy). I needed something for parsing command line arguments, and kind of wanted something like Python’s argparse module. This library is what I ended up with.

(It actually ended up diverging from Python’s argparse quite a bit, partly because the languages do certain things differently, and partly because there were things in argparse I never really liked.)

The result is (I hope!) easy to use and concise yet powerful and robust.

Feedback would be appreciated.


#2

kotlin-argparser 2.0 has been released.

There have been a bunch of improvements since 1.0 including:

  • (optional) auto-naming of options and positional arguments
  • better help formatting
  • support for multi-arg option types
  • better type handling of defaults
  • improved documentation
  • many bug fixes.

Note that there are some incompatibilities with the 1.x releases. The release notes discuss these in more detail.