Does Perl have a module similar to docopt?

ぐ巨炮叔叔 提交于 2020-01-14 14:18:25

问题


Is there any Perl module that have similar functionality to Docopt or is there a port being developed for it?

Docopt is a module that creates an interface for command line calls from parsing the usage and options messages.

You create the standard help message like

    Naval Fate.

    Usage:
      naval_fate ship new ...
      naval_fate ship  move   [--speed=]
      naval_fate ship shoot  
      naval_fate mine (set|remove)   [--moored|--drifting]
      naval_fate -h | --help
      naval_fate --version

    Options:
      -h --help     Show this screen.
      --version     Show version.
      --speed=  Speed in knots [default: 10].
      --moored      Moored (anchored) mine.
      --drifting    Drifting mine.

and then the options handler is created for you instead of writing them again with Getopt::Long and also handle the commands parsing (I use App::Cmd for that).

Seems that it started in Python and now is implemented in many other languages.

http://docopt.org/

https://github.com/docopt/docopt


回答1:


Perl has Docopt as pointed out in the comments by @marderh. In addition, there are other modules that provide similar functionality such as Getopt::Auto, Getopt::Euclid, Getopt::AsDocumented …



来源:https://stackoverflow.com/questions/18336946/does-perl-have-a-module-similar-to-docopt

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!