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

Please add perl implementation #5

Open
tokuhirom opened this issue Jun 10, 2013 · 12 comments
Open

Please add perl implementation #5

tokuhirom opened this issue Jun 10, 2013 · 12 comments

Comments

@tokuhirom
Copy link

https://github.com/tokuhirom/Docopt

I wrote a perl implementation.

@keleshev
Copy link
Member

Great!

  1. Do you want to be part of docopt organization? If yes you can transfer your repo to docopt/docopt.pl and I will grant you push access.
  2. Are you aware of the language-agnostic test suit?
  3. I suggest using MIT license as all other ports, if you don't mind.

@tokuhirom
Copy link
Author

  1. No. I don't want to join the org. I don't like github org.
  2. Oh, I don't know about that! How to run it? Is it documented anywhere?
  3. Okay, I'll do it.

@keleshev
Copy link
Member

  1. Oh, why not? I think it would be great to have all docopt implementations in the same place (under one organization).
  2. It is not well documented, but the idea is that testcases.docopt is 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.

@tokuhirom
Copy link
Author

  1. I do that on msgpack project. github send me a lot of non-intereseted messages.
  2. Okay, I'll try this.

@keleshev
Copy link
Member

  1. 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?

@tokuhirom
Copy link
Author

I suggest you to create testcases.docopt to JSON converter. It helps porters.

@tokuhirom
Copy link
Author

I ported from docopt's HEAD. Then I use testcases.docopt from HEAD :P

@keleshev
Copy link
Member

keleshev commented Aug 1, 2014

@tokuhirom do you still not want to consider joining the github org? 😉

@alexchandel
Copy link

@keleshev tokuhirom's port hasn't been updated in over a year. Could it be copied to this organization for further work?

@keleshev
Copy link
Member

@alexchandel what kind of further work does it require? Do you want to do it?

@alexchandel
Copy link

@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.

@rfdrake
Copy link

rfdrake commented Dec 7, 2015

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.

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

4 participants