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

Please add perl implementation

Open tokuhirom opened this issue 12 years ago • 12 comments

https://github.com/tokuhirom/Docopt

I wrote a perl implementation.

tokuhirom avatar Jun 10 '13 08:06 tokuhirom

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.

keleshev avatar Jun 10 '13 10:06 keleshev

  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.

tokuhirom avatar Jun 10 '13 11:06 tokuhirom

  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.

keleshev avatar Jun 10 '13 13:06 keleshev

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

tokuhirom avatar Jun 10 '13 13:06 tokuhirom

  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?

keleshev avatar Jun 10 '13 13:06 keleshev

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

tokuhirom avatar Jun 11 '13 09:06 tokuhirom

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

tokuhirom avatar Jun 11 '13 12:06 tokuhirom

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

keleshev avatar Aug 01 '14 09:08 keleshev

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

alexchandel avatar Feb 21 '15 19:02 alexchandel

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

keleshev avatar Feb 22 '15 20:02 keleshev

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

alexchandel avatar Feb 23 '15 02:02 alexchandel

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.

rfdrake avatar Dec 07 '15 19:12 rfdrake