Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docopt cannot find the docstring #4

Open
fglaros opened this issue Aug 19, 2013 · 1 comment
Open

docopt cannot find the docstring #4

fglaros opened this issue Aug 19, 2013 · 1 comment

Comments

@fglaros
Copy link

fglaros commented Aug 19, 2013

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.

@signalpillar
Copy link

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:

  1. I have made pull request where macros replaced with function
  2. Regarding meta usage - while running current namespace (*ns*) points to the user namespace. To overcome this issue I have bound *ns* to mine but I am not sure it is idiomatically correct decision. Here is my example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants