l3nz / cli-matic

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

[Ftr] Babashka compatibility #113

Closed l3nz closed 2 years ago

l3nz commented 4 years ago

Is your feature request related to a problem? Please describe. CLI-matic does not work on Babashka, as it references clojure.spec and expound, and those are not supported by Babashka.

Describe the solution you'd like

Ideally, I'd love to load a mock 'clojure.spec.alpha' if there is none, that could be an alias of https://github.com/borkdude/spartan.spec/

It looks like it could be possible:

(when (= (System/getenv "ENV") "TEST")
  (ns-unalias 'example 'memcache)
  (require 'test.cache.fake)
  (alias 'memcache 'test.cache.fake))

Not sure if this would work on SCI though - https://github.com/borkdude/babashka#differences-with-clojure looks promising anyway

See http://blog.josephwilk.net/clojure/isolating-external-dependencies-in-clojure.html

l3nz commented 4 years ago

An alternative could be a reader conditional where we bind:

     [clojure.spec.alpha :as s]

And then another one to mock s/fdef with (fn [_] nil).

borkdude commented 4 years ago

You can also do a lot with reader conditionals. Babashka supports the :bb reader conditional.

AndreTheHunter commented 4 years ago

@lread have you started implementing Babashka support? I'm very keen to see this and lend a hand if needed

l3nz commented 4 years ago

Not really but I plan to. In theory I guess we should:

AndreTheHunter commented 4 years ago

Not really but I plan to. In theory I guess we should:

  • import the spartan.spec instead of spec
  • make expound optional
  • I guess most of the platform stuff is simply JVM.

OK I'll get on it 😁 I'll create a draft PR for you to look at soon

AndreTheHunter commented 4 years ago

Well I've made a start https://github.com/l3nz/cli-matic/pull/128 I'll need to create a PR for https://github.com/borkdude/babashka too, since there are some things missing that are needed by cli-matic

borkdude commented 4 years ago

FWIW, babashka is now released with the PR included.

l3nz commented 4 years ago

@AndreTheHunter just womndering if you had some progress on this feature.

l3nz commented 3 years ago

Looks like @borkdude made it work - https://github.com/borkdude/spartan.spec/blob/master/examples/cli_matic.clj !

borkdude commented 2 years ago

Made a PR here: https://github.com/l3nz/cli-matic/pull/145

borkdude commented 2 years ago

One more thought concerning babashka, but can he handled in a follow up: bb comes with clj-yaml.core maintained under clj-commons. If you would switch to that version, the YAML-related features would work with bb too.