l3nz / cli-matic

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

Allow multiline values for :as in options. #95

Closed lread closed 4 years ago

lread commented 4 years ago

The value for :as acts as an option's description. Like the :app and :command :description, :as now optionally supports multiline text via a vector of strings.

Notes: Cli-matic takes advantage of clojure.tools.cli to format options for display in help. Ideally clojure.tools.cli would accept multiline descriptions for options, but it does not.

The route I took was to markup the multiline option description as a string before sending it to clojure.tools.cli then fixing it up the resulting generated summary afterward.

Another approach would be to use a custom :summary-fn for clojure.tools.cli, but I thought this would be more of an issue to maintain than a fixup approach.

This work includes the strengthening of the spec for descriptions. A description must be a non-blank string - or - a collection of strings that includes at least one non-blank string.

I also moved the beef of get-clojure-options under utils as that provided me the fixup symmetry I was looking for.

Fixes #94

lread commented 4 years ago

If you are interested, I can work on a 2nd PR using the :summary-fn approach Might be nice to compare the 2 approaches.

lread commented 4 years ago

See #96 for alternate solution that uses :summary-fn.