Keep it simple
I'm not sure if it's a good idea to expose so much functionality:
-
docopt.core.docopt -
docopt.core.match -
docopt.core.parse
I can understand that compile-time/run-time parsing could be a trade-off, but what one supposed to do with docopt.core.parse?
I wish it was as simple as docopt.docopt as in other implementations, but I can understand that languages, conventions, and needs might be different.
I'm not too sure either, but based on my limited understanding of how things are done in clojure, it's OK. Basically, a consequence of the immutability of clojure data structures is that idiomatic clojure doesn't hide their contents.
To answer your question, you could want to call docopt.core/parse to test the validity of a docstring: it's invalid if it throws an exception. I was thinking of maybe also have it log some warnings. As of now, docopt.core/match is called for testing in the docopt.test_core namespace.
I changed docopt.core a bit and replaced match with a java class method for JVM interop, see README for more info.
Hey @postamar, I would like to help with the development of docopt.clj. I am also new to Clojure but I have some ideas of how to improve its simplicity. As some remarks:
;instead of
(defn func-name [])
;use
(defn- func-name [])
;for non-public functions as https://clojuredocs.org/clojure.core/defn-
Also according to this documentation it is not necessary that you put the docstring inside metadata, but rather after the name of the function. It should be automatically recognized.
(defn -main
"This is my docstring"
[ & args])
As I said, I would like to work on this, but yesterday I tried to modify your code and I couldnt even get the same code on the README to run. Could you please give me a quick overview over what is what there and how to hack into it? :)