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

docopt

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

docopt

a command line option parser that will make you smile

  • 0.6.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is docopt?

The docopt npm package is a command-line interface (CLI) argument parser that helps you define the interface for your CLI programs. It uses a simple and intuitive syntax to specify the command-line arguments, options, and usage patterns, and then automatically parses the arguments based on that specification.

What are docopt's main functionalities?

Basic Argument Parsing

This feature allows you to define and parse basic command-line arguments. In this example, the program expects a 'name' argument and an optional '--greet' flag.

const docopt = require('docopt').docopt;
const doc = `Usage: myprogram <name> [--greet]`;
const options = docopt(doc, { argv: process.argv.slice(2) });
console.log(options);

Handling Multiple Commands

This feature allows you to define and handle multiple commands within a single CLI program. In this example, the program can either 'add' or 'remove' a 'name'.

const docopt = require('docopt').docopt;
const doc = `Usage:
  myprogram add <name>
  myprogram remove <name>`;
const options = docopt(doc, { argv: process.argv.slice(2) });
console.log(options);

Optional and Required Arguments

This feature allows you to specify optional and required arguments. In this example, 'input' is required, 'output' is optional, and '--verbose' is an optional flag.

const docopt = require('docopt').docopt;
const doc = `Usage: myprogram [--verbose] <input> [<output>]`;
const options = docopt(doc, { argv: process.argv.slice(2) });
console.log(options);

Other packages similar to docopt

Keywords

FAQs

Package last updated on 13 Apr 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