babashka / cli

Turn Clojure functions into CLIs!
MIT License
232 stars 18 forks source link

docs: consider revising validation point under main ideas #63

Closed lread closed 10 months ago

lread commented 1 year ago

First, Kudos!

The more I use babashka/cli, the more I like it!

Currently

The readme states:

Because the line between calling functions from the command line and Clojure itself is blurred, validation of arguments should happen in your Clojure function, using your favorite tools (manually, spec, schema, malli...). As such, the library only focuses on coercion: turning argument strings into data which is then passed to your function.

I expect, it was after this was originally written, that babashka/cli has added argument validation support.

A use case I am looking at is using babashka/cli for an existing Clojure JVM project that supports both -M and -X invocations (the latter via Clojure tools).

I would love to share validation for both of these entrypoints, but I don't think that is a goal of babashka/cli. Perhaps babahka/bbin is a command-line-friendly alternative to Clojure tools.

So maybe

  1. Update the quoted idea above. It is still valid to validate in-function if you need validation to occur for multiple entry-points, but it is no longer true that babashka/cli focuses only on coercion.
  2. Maybe add some words on how babashka/cli is not in the business of directly making -X style invocations more command-line friendly, but it certainly can make command-line friendly -M style invocations that can delegate to -X targets.
  3. Consider adding a pointer/tip for babashka/bbin as a potential command-line-friendly alternative to Clojure Tools. Is that a goal of bbin?

Next Steps

There is always a good chance that I've misunderstood - maybe some or all of the above is not correct. Lemme know.

If you are interested, I can draft up doc changes in a PR for your review.

borkdude commented 1 year ago

I think you can validate with you use the :validate option in your :org.babashka/cli metadata, right? Yes, that part was written before that existed, but the validation will only happen if you invoke the function through babashka CLI.

borkdude commented 1 year ago

Thanks for the compliment btw!

lread commented 1 year ago

Oh, apologies, I forgot to follow up! Thanks for the response, makes sense, of course.

Jet is an example project that supports both -X and -M calling styles with shared processing/validation.

I'm not sure this even needs to be clarified in the README, but can-do if you want. Otherwise, feel free to close this sissue.

borkdude commented 1 year ago

Yeah, I think it would help

borkdude commented 10 months ago

I just deleted the confusing section.