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.
https://github.com/xenomachina/kotlin-argparser
7 Likes
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.
3 Likes
Hi, very interesting project, I am developing a technology stack that is Kotlin/Multiplatform.
I saw that some code import from the java world, my project must stick to the Multiplatform scene, so wonder if this will be available in Kotlin/Common?
The project in question doesn’t seem to be actively developed, but you may want to have a look into Clikt. It seems to be currently the most popular multiplatform library for the arguments parsing.
HI, I was looking at the code, I see that there is lot of java legacy and some other type of legacy code outside commonMain, I am myself implementing a setup of infrastructure that solely runs on JNI and POSIX, also having my own ByteBuffer better than the one in java. I would like to see if possible to build with this interface of Clikt and with my JNI bottom plate.
1 Like