问题
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