Skip to content

davebaird/python-docopt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Python::Docopt

Use the Python docopt utility in Perl.

use Python::Docopt ;
use Encode qw(decode_utf8) ;
@ARGV = map { decode_utf8( $_, 1 ) } @ARGV ;

sub usage {
    return <<EOF;
Naval Fate.

Usage:
    naval_fate ship new <name>...
    naval_fate ship <name> move <x> <y> [--speed=<kn>]
    naval_fate ship shoot <x> <y>
    naval_fate mine (set|remove) <x> <y> [--moored|--drifting]
    naval_fate -h | --help
    naval_fate -v | --version

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

# -----
my $opts = docopt( decode_utf8( usage() ) ;

warn 'Too fast' if $opts->{'--speed'} > 20 ;

About

Perl wrapper for the Python docopt library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published