Comment made by: mfikes
The attached patch works, but there are some things I like, and some things I don't like.
It is nice that it declaratively adds specs to the commands and enhances the runtime a little to validate these specs.
But, while this feels like "input validation", another argument is that, if the compiler is going to employ specs, some, like optimization levels could be deeper in the system (which would also catch misconfiguration of compiler option edn).
Anyway, even though I'm not completely happy with the patch, attaching it in case it inspires a better approach.
Here is what you see with the patch for the example in the ticket description.
`
$ clj -m cljs.main -O adv -c chambered.core
Exception in thread "main" clojure.lang.ExceptionInfo: Invalid level: val: "adv" fails spec: :cljs.cli/optmizations predicate: #{"none" "advanced" "whitespace" "simple"}
{}
at clojure.core$ex_info.invokeStatic(core.clj:4739)
at clojure.core$ex_info.invoke(core.clj:4739)
at cljs.cli$add_commands$maybe_wrap_fn__8772$fn__8774.invoke(cli.clj:424)
at cljs.cli$initialize$fn__8714.invoke(cli.clj:235)
at clojure.lang.PersistentVector.reduce(PersistentVector.java:341)
at clojure.core$reduce.invokeStatic(core.clj:6747)
at clojure.core$reduce.invoke(core.clj:6730)
at cljs.cli$initialize.invokeStatic(cli.clj:233)
at cljs.cli$initialize.invoke(cli.clj:230)
at cljs.cli$main.invokeStatic(cli.clj:543)
at cljs.cli$main.doInvoke(cli.clj:531)
at clojure.lang.RestFn.applyTo(RestFn.java:139)
at clojure.core$apply.invokeStatic(core.clj:659)
at clojure.core$apply.invoke(core.clj:652)
at cljs.main$_main.invokeStatic(main.clj:60)
at cljs.main$_main.doInvoke(main.clj:52)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.lang.Var.applyTo(Var.java:702)
at clojure.core$apply.invokeStatic(core.clj:657)
at clojure.main$main_opt.invokeStatic(main.clj:317)
at clojure.main$main_opt.invoke(main.clj:313)
at clojure.main$main.invokeStatic(main.clj:424)
at clojure.main$main.doInvoke(main.clj:387)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.lang.Var.applyTo(Var.java:702)
at clojure.main.main(main.java:37)
`