l3nz / cli-matic

Compact, hands-free [sub]command line parsing library for Clojure.
Eclipse Public License 2.0
360 stars 28 forks source link

[Ftr] Ability to extend type presets, like `:file` for conforming the arg to `File` #157

Open bartkl opened 1 year ago

bartkl commented 1 year ago

Is your feature request related to a problem? Please describe. The current presets are nice, but I would like to be able to extend them.

Describe the solution you'd like My current use case is getting a file name from the CLI, and I would like to specify this to be of :type :file. This :file preset is what I would like to be able to add, so that this argument will be parsed as File object or give an error. Of course, a general solution is desired for extending types.

Describe alternatives you've considered I looked at the cli-matic source code to try and figure something out myself. But it seems it's relatively hard to extend this. Writing a preset function is easy, but you then have to update presets/known-presets and, the more cumbersome, ::type spec. And perhaps more, I'm not entirely confident I understood it all.

Version / Platform

$ java --version
openjdk 11.0.11 2021-04-20
OpenJDK Runtime Environment 18.9 (build 11.0.11+9)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.11+9, mixed mode)
$ clj --version
Clojure CLI version 1.11.1.1113
$ grep cli-matic project.clj 
[cli-matic "0.5.3"]