docopt.org
docopt.org copied to clipboard
Please add perl implementation
https://github.com/tokuhirom/Docopt
I wrote a perl implementation.
Great!
- Do you want to be part of docopt organization? If yes you can transfer your repo to
docopt/docopt.pland I will grant you push access. - Are you aware of the language-agnostic test suit?
- I suggest using MIT license as all other ports, if you don't mind.
- No. I don't want to join the org. I don't like github org.
- Oh, I don't know about that! How to run it? Is it documented anywhere?
- Okay, I'll do it.
- Oh, why not? I think it would be great to have all docopt implementations in the same place (under one organization).
- It is not well documented, but the idea is that
testcases.docoptis a set of test-cases of form:
r"""usage: prog (-a -b)
options:
-a
-b
"""
$ prog -a -b
{"-a": true, "-b": true}
$ prog -b -a
{"-a": true, "-b": true}
Inside r"""...""" you have your doc parameter. Then $ prog is followed by ARGV. And next line is a return value of docopt as JSON or "user-error" in case ARGV is invalid. Each docopt implementation creates its own test-runner for this file.
I recommend you to use testcase.docopt from latest tag (0.6.1), not from master, because master is a moving target.
Feel free to ask me questions.
- I do that on msgpack project. github send me a lot of non-intereseted messages.
- Okay, I'll try this.
- Oh, don't worry you can select either "watching", "not watching" or "ignoring" for each repository, so it's not a problem. I would really like to see all docopt implementations in one place. Give it a try! If you don't like it you can move you repository back. What do you think?
I suggest you to create testcases.docopt to JSON converter. It helps porters.
I ported from docopt's HEAD. Then I use testcases.docopt from HEAD :P
@tokuhirom do you still not want to consider joining the github org? :wink:
@keleshev tokuhirom's port hasn't been updated in over a year. Could it be copied to this organization for further work?
@alexchandel what kind of further work does it require? Do you want to do it?
@keleshev I mentioned a few issues in the repo, but it basically isn't usable. Sadly I'm not experienced enough in Perl to maintain it, but I may be able to offer a branch.
I was about to open an issue against the project because I'm having problems with some things. I think the testcases.docopt could use some extra cases for a few things it doesn't cover right now.
~~Here is an example of where the perl code falls over but passes tests:~~
usage:
program [options]
--coefficient=K The K coefficient [default: 2.95]
--output=FILE Output file [default: test.txt]
--directory=DIR Some directory [default: ./]
~~This doesn't work in perl, but it works in the "docopt in the browser" page.~~
EDIT: A few days of hacking later I've decided there isn't anything wrong with Docopt.pm. I'm not sure why this works on the web interface, but it should have required "options:" before the options.
~~I think it would be good to test for a complicated line line this in the test suite:~~
-d DIR --directory=DIR Some directory [default: ./]
EDIT: This works too, once you get around the parser errors caused by Pod::Usage.
~~As well as testing more than one option line to make sure it doesn't get confused parsing multiple lines. Testing the "help" output might also be good, since the perl implementation is breaking on that too:~~
Usage:
usage: program [options]
--coefficient=K The K coefficient [default: 2.95] --output=FILE Output
file [default: test.txt] --directory=DIR Some directory [default: ./]
EDIT: All of that was caused by Pod::Usage. If you indent the input then Pod formats it properly and Docopt.pm can read it. I'm submitting patches to Docopt.pm to update the documentation for clarity.