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] Succint error messages that don't show spec boilerplate #136

Open kiramclean opened 3 years ago

kiramclean commented 3 years ago

Is your feature request related to a problem? Please describe. This is not a big problem, just a mere suggestion. I'm proposing making the error messages just short, simple messages, without showing anything related to spec. E.g. at the moment I've got a small CLI set up where one of the arguments is an input directory. I use spec validation to check that the directory exists, and expound to add a nicer error message, but the user still sees this unwieldy message if they pass in something that fails the validation:

** ERROR: **
Global option error: Spec failure for global option 'input'
-- Spec failed --------------------

  "/Users/kira/does/not/exist"

Directory must exist.

-- Relevant specs -------

:indexer.core/input-dir:
  babashka.fs/exists?

-------------------------
Detected 1 error

(The "directory must exist" part is my custom expound message).

Also I should add it's entirely possible that I've just got it set up wrong. I'm notoriously mediocre at using other people's libraries with success. The app config can be found in this public repo.

Describe the solution you'd like It would be more conventional and I'd argue more user-friendly if the error message were simply something like "An error occurred: Directory must exist." (or "directory was not found. Please provide a directory that exists", or whatever).

Describe alternatives you've considered I like how high-level cli-matic is, so I get that maybe it wouldn't make sense to give the (library) user full control over the entire error message, but omitting the spec stuff should be an option, imo.

Thank you for this great library, and for reading this issue!

l3nz commented 3 years ago

The idea of Expound was having messages (especially with Spec) that made a bit more sense than the usual 100+ lines of headache.

Maybe your issue could be that you would like an escape hatch so you can generate a custom message by triggering an exception?