Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fdocopt

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fdocopt

> File decorator for [docopt] option parser.

  • 0.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
27
increased by237.5%
Maintainers
1
Weekly downloads
 
Created
Source

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 */');

FAQs

Package last updated on 25 May 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc