Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Perl have a module similar to docopt?

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

like image 415
Pablo Marin-Garcia Avatar asked Sep 20 '25 06:09

Pablo Marin-Garcia


1 Answers

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 …

like image 73
Sinan Ünür Avatar answered Sep 23 '25 11:09

Sinan Ünür



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!