Rob Elliot
07/02/2021, 11:42 AMURI
or a Path
, which I’ll then turn into a URI
. So accept any of:
file:///tmp/whatever
/tmp/whatever
- will resolve to file:///tmp/whatever
foo
- will resolve to file:///currentdir/foo
<http://example.com>
Obviously I can do it in a call to convert
but I’d quite like to reuse com.github.ajalt.clikt.parameters.types.path
- but it can only be called on a RawArgument
, and it delegates to an internal function so I can’t call that.Rob Elliot
07/02/2021, 11:44 AMAJ Alt
07/02/2021, 5:59 PMoption().path().convert {it.toURI()}
, but that's only for successful cases. The path validation is pretty simple, I'd suggest just copying the parts you care about into your own convert
(https://github.com/ajalt/clikt/blob/a220c2c9173df9dace0c2a87f9bff86b211b6428/clikt/src/jvmMain/kotlin/com/github/ajalt/clikt/parameters/types/path.kt#L37).Rob Elliot
07/02/2021, 6:46 PM