ClojureScript docopt

Probably many of you know that I’m creating a CLI utility on top of nodejs with ClojureScript.
I don’t know if you know about it (there is no post on that topic) docopt is a generic documentation specification with parsers written in many languages. I was wondering if you know of any implementation on ClojureScript.
There is an implementation on node, and one implementation on Clojure. The Clojure one seems to use some Java classes like hasmap, so I don’t think it will work on ClojureScript.

Do you know about a ClojureScript implementation? If not, I may think about porting the node or the Clojure version. Which one do you find better more suitable? Porting the nodejs one will be a matter of adding a wrapper, not reimplementing it


1 Like

Don’t know about docopt but you could use tools.cli which works in CLJ+CLJS.

Besides that you could just use the docopt npm JS package directly. Seems to have a very simple interface.

The advantages of docopt over tools.cli are many:

  • It takes care of proper error reporting to the user, you just get correct input
  • It has sub-commands
  • It takes care that the sub-commands only get the options they are supposed to get
  • The documentation output is very clear since you just write it, no need to understand the code

Of course I can use just the JS package, as you said the interface is very simple. However I’m trying to goo full cljs, but I found myself using more JS libraries than cljs ones. Actually I don’t use any cljs library apart from the native ones, and this would be the second JS addition to my current project.

Good JS Interop is one of the strengths of CLJS so it is totally fine to use it IMHO.

1 Like

I also use way more js libraries than cljs libraries in my projects.

1 Like