ajalt / clikt

Multiplatform command line interface parsing for Kotlin
https://ajalt.github.io/clikt/
Apache License 2.0
2.51k stars 121 forks source link

Support path arguments for native #492

Open mgroth0 opened 6 months ago

mgroth0 commented 6 months ago

Title says it all. Using something like kotlinx-io to support even a subset of the path features in native would be excellent

JakeWharton commented 6 months ago

Since that library is not stable, you're better off doing a manual convert for now. I suspect once it does go stable it will be supported.

You could also use Okio's multiplatform file system. It is stable, but I wouldn't expect Clikt to take it as a dependency for built-in support. Example:

https://github.com/JakeWharton/video-swatch/blob/trunk/src/commonMain/kotlin/com/jakewharton/videoswatch/main.kt#L69-L70

ajalt commented 6 months ago

I don't generally have library-specific extensions since calling .convert { it.toWhatever } seems easy enough. But since paths have some extra validation functionality like canBeFolder, it might make sense to provide that once kotlinx-io is stable.

mgroth0 commented 6 months ago

@JakeWharton I actually wasn't aware about okio for native filesystem operations. I tried it and it is working really well. Thank you!

And @ajalt, you are right and that is exactly why I made this issue. Because the JVM API is more than just a conversion but also has fancy checks like canBeFolder, it would seem beneficial to support than more evenly across platforms if possible.