fdocopt
> File decorator for [docopt] option parser.
Last updated 12 years ago by valeriangalliat .
Unlicense · Repository · Bugs · Original npm · Tarball · package.json
$ npm install fdocopt 
SYNC missed versions from official npm registry.

fdocopt npm version

File decorator for docopt option parser.

Description

It's not easy to work with docopt in pure JavaScript since, unlike Python and CoffeeScript, there's no simple way to define a multiline string to contain the usage string.

This package provides a decorator for docopt to solve this problem.

/*
Usage: hello [options] <world>

Arguments:
  <world>  Hello world!

Options:
  -h, --help  Show this help.
  --version   Show version.
  --happy     Be happy.
*/

var docopt = require('fdocopt')();

By default it will decorate the global docopt instance, so the above is the same as:

var docopt = require('fdocopt')(require('docopt').docopt);

Then, pass the documented filename instead of the usage string:

var args = docopt(__filename);

You can also use the internal functions to extract the comment block from a file or a code buffer:

var doc = require('fdocopt').extract(__filename);
var doc = require('fdocopt').extractBuffer('/** Usage: hello */');

Current Tags

  • 0.1.3                                ...           latest (12 years ago)

3 Versions

  • 0.1.3                                ...           12 years ago
  • 0.1.2                                ...           12 years ago
  • 0.1.0                                ...           12 years ago
Maintainers (1)
Downloads
Total 2
Today 0
This Week 0
This Month 2
Last Day 0
Last Week 2
Last Month 0
Dependencies (1)
Dev Dependencies (1)
Dependents (0)
None

© 2010 - cnpmjs.org x YWFE | Home | YWFE