Better HN
topnewbestaskshowjobs
Log inSign up

halst

427 karma · joined Jun 4, 2012 (14y ago) · 57 submissions

Submissions

31.

WWDC14 Developer Fan Fiction(keleshev.com ↗)

2 points · by halst · 12y ago · discuss

32.

:help iccf(teespring.com ↗)

1 points · by halst · 12y ago · discuss

33.

Implement a programming language in 55 minutes(youtube.com ↗)

3 points · by halst · 13y ago · discuss

34.

VI Gang Sign(github.com ↗)

1 points · by halst · 13y ago · discuss

35.

Schema validation just got Pythonic(github.com ↗)

3 points · by halst · 14y ago · discuss

36.

The greatest PL talk of all time(youtube.com ↗)

3 points · by halst · 14y ago · 1 comment

comment 14y ago · link · parent

About long options repeated: you can either specify "[options]" shortcut in a pattern in order not to put all options in that pattern, or you can have all options listed in the pattern--then you can avoid having them in option description.

About repeating program's name (say "naval_fate"), you can do:

    """Usage: prog <bla> ...
              prog <bla> --bla
    """
    args = docopt(__doc__.replace('prog', 'naval_fate'))

comment 14y ago · link · parent

One of the early versions of docopt (0.1) was ported to bash: https://github.com/colinta/bocopsh

It should be relatively easy to update it to work with 0.4; if you can make it work with 0.4 it would be great if you make a pull request to the project above.

comment 14y ago · link · parent

Quite similar approach. But I think usage-pattern matching is where docopt shines.

comment 14y ago · link · parent

You can just change the second line to:

    naval_fate ship move <name> <x> <y> [--speed=<kn>]
to eliminate all the problems you named. Those problems are about specific interface, not docopt.

comment 14y ago · link · parent

But I must warn you: Ruby port (as of now) implements only a small subset of docopt language, but we're working on it.

comment 14y ago · link · parent

Thanks a lot for the link. Your suggestion will probably make into next version of docopt.

comment 14y ago · link · parent

Getopt::Euclid from CPAN is also very similar.

comment 14y ago · link · parent

docopt will maybe borrow a few ideas from dreamopts.js :-) Would you like to join forces on [docopt.coffee](https://github.com/docopt/docopt.coffee)?

comment 14y ago · link · parent

When the DSL (http://docopt.org/) was designed, the main goal was just to formalise that pattern-language used for decades in man pages and `--help` screens. So variations that are conventional (such as `UPPER-CASE` for arguments or `<angular-brackets>` for arguments) are supported.

comment 14y ago · link · parent

I think Clap is good. But you can't beat the readability and succinctness of a DSL (docopt).

comment 14y ago · link · parent

Right now we have two full-blown working implementations: - Python - CoffeeScript

We have just started to port to Ruby and Lua. All ports live under `docopt` organization on GitHub: https://github.com/docopt

You are very welcome to help us out with Ruby, Lua, and your favorite language :-).

comment 14y ago · link · parent

I'm also a fan of idea of using function-docstrings for separate subcommand help-screens. Problems: (1) exact API, (2) how to do that in non-python implementations. You (and everyone) is very welcome to suggest APIs for that in issues: https://github.com/docopt/docopt/issues

comment 14y ago · link · parent

BTW, about bad pitch: maybe :-)

I wanted to improve on presentation, since my last post: http://news.ycombinator.com/submitted?id=halst

comment 14y ago · link · parent

docopt is even more terse than 1 line per argument/option/command.

Take an example:

    Usage: quick_example.py tcp <host> <port> [--timeout=<seconds>]
           quick_example.py serial <port> [--baud=9600] [--timeout=<seconds>]
           quick_example.py -h | --help | --version

2 commands, 3 arguments, 5 options: in only 3 lines of DSL.

Take a look at more examples: https://github.com/docopt/docopt/tree/master/examples

comment 14y ago · link · parent

You can already have deeply nested subcommands in docopt, take this example: https://github.com/docopt/docopt/blob/master/examples/git_ex...

Making possible several help-screens for different commands is on it's way. The only stopper—deciding on API: https://github.com/docopt/docopt/issues/17

comment 14y ago · link · parent

That exactly what [docopt](http://docopt.org/) is—DSL that allows implement almost any interface in one line (having formal interface description).

53.

Challenge: Implement CLI interface like that?(challenge.docopt.org ↗)

74 points · by halst · 14y ago · 46 comments

comment 14y ago · link · parent

I know a tiny bit of Lua. Write me halst@ya.ru or skype "halst." we can discuss your Lua port.

comment 14y ago · link · parent

It should be easy to port it - docopt is only 366 LOC itself.

comment 14y ago · link · parent

wow, great! what is your scripting language?

57.

Docopt creates beautiful command-line interfaces(docopt.org ↗)

7 points · by halst · 14y ago · 7 comments

12