docopt.clj icon indicating copy to clipboard operation
docopt.clj copied to clipboard

Keep it simple

Open keleshev opened this issue 12 years ago • 3 comments

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.

keleshev avatar Mar 31 '13 12:03 keleshev

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.

postamar avatar Mar 31 '13 18:03 postamar

I changed docopt.core a bit and replaced match with a java class method for JVM interop, see README for more info.

postamar avatar Apr 02 '13 14:04 postamar

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? :)

carocad avatar Aug 19 '15 08:08 carocad