docopt cannot find the docstring
Using lein 2.2.0, clojure 1.5.1 on Windows when I try to use (docopt args) I receive an error that a docstring on -main could not be found. (The assert string? fails)
I replicated the error using a vanilla project with the example provided (Naval Fate) and received the same error. Tried to place the docstring on a seperate value (def usage "Naval Fate ...") and pass that to docopt. Received the same error again. It only managed to compile when giving the docstring directly as an argument to docopt.
Quite likely that I am missing something very obvious since my knowledge regarding macros is limited.
I have the same issue using Leiningen 2.3.1 on Java 1.7.0_21 Java HotSpot(TM) 64-Bit Server VM
Caused by: java.lang.Exception: Docopt with one argument requires that #'-main have a doc string.
I have tried to define doc string as variable and pass as first parameter for the docopt call, but then it fails assert string? in parser
One thing that works for me is to pass string literal as first parameter to the docopt. Seems like it is somehow related to the fact that docopt is a macros ..
UPD:
([doc args]
`(m/match-argv ~(parse doc) ~args)))
Seems like - the expression (parse doc) will be evaluated in compile time where doc will be just a symbol
UPD2:
- I have made pull request where macros replaced with function
- Regarding meta usage - while running current namespace (
*ns*) points to theusernamespace. To overcome this issue I have bound*ns*to mine but I am not sure it is idiomatically correct decision. Here is my example