yargs
yargs the modern, pirate-themed, successor to optimist.
Last updated 24 days ago by bcoe .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install yargs 
SYNC missed versions from official npm registry.

Yargs

Yargs be a node.js library fer hearties tryin' ter parse optstrings


Build Status Coverage Status NPM version Windows Tests js-standard-style Conventional Commits Slack

Description :

Yargs helps you build interactive command line tools, by parsing arguments and generating an elegant user interface.

It gives you:

  • commands and (grouped) options (my-program.js serve --port=5000).
  • a dynamically generated help menu based on your arguments.
  • bash-completion shortcuts for commands and options.
  • and tons more.

Installation

Stable version:

npm i yargs --save

Bleeding edge version with the most recent features:

npm i yargs@next --save

Usage :

Simple Example

#!/usr/bin/env node
const argv = require('yargs').argv

if (argv.ships > 3 && argv.distance < 53.5) {
  console.log('Plunder more riffiwobbles!')
} else {
  console.log('Retreat from the xupptumblers!')
}
$ ./plunder.js --ships=4 --distance=22
Plunder more riffiwobbles!

$ ./plunder.js --ships 12 --distance 98.7
Retreat from the xupptumblers!

Complex Example

#!/usr/bin/env node
require('yargs') // eslint-disable-line
  .command('serve [port]', 'start the server', (yargs) => {
    yargs
      .positional('port', {
        describe: 'port to bind on',
        default: 5000
      })
  }, (argv) => {
    if (argv.verbose) console.info(`start server on :${argv.port}`)
    serve(argv.port)
  })
  .option('verbose', {
    alias: 'v',
    default: false
  })
  .argv

Run the example above with --help to see the help for the application.

Community :

Having problems? want to contribute? join our community slack.

Documentation :

Table of Contents

Current Tags

  • 12.0.5                                ...           latest (24 days ago)
  • 12.0.5                                ...           next (24 days ago)

162 Versions

  • 12.0.5                                ...           24 days ago
  • 12.0.4                                ...           a month ago
  • 12.0.3-candidate.0                                ...           2 months ago
  • 12.0.2                                ...           3 months ago
  • 12.0.1                                ...           5 months ago
  • 12.0.0                                ...           6 months ago
  • 12.0.0-candidate.0                                ...           8 months ago
  • 11.1.0                                ...           9 months ago
  • 11.0.0                                ...           a year ago
  • 10.1.2                                ...           a year ago
  • 10.1.1                                ...           a year ago
  • 10.1.0                                ...           a year ago
  • 10.0.3                                ...           a year ago
  • 10.0.2                                ...           a year ago
  • 10.0.1                                ...           a year ago
  • 10.0.0                                ...           a year ago
  • 10.0.0-alpha.4                                ...           a year ago
  • 10.0.0-alpha.3                                ...           a year ago
  • 10.0.0-alpha.2                                ...           a year ago
  • 10.0.0-alpha.1                                ...           a year ago
  • 10.0.0-alpha.0                                ...           a year ago
  • 9.0.1                                ...           a year ago
  • 9.0.0                                ...           a year ago
  • 8.0.2                                ...           2 years ago
  • 8.0.1                                ...           2 years ago
  • 8.0.0                                ...           2 years ago
  • 8.0.0-candidate.1                                ...           2 years ago
  • 8.0.0-candidate.0                                ...           2 years ago
  • 7.1.0                                ...           2 years ago
  • 7.0.2                                ...           2 years ago
  • 7.0.2-candidate.1                                ...           2 years ago
  • 7.0.1                                ...           2 years ago
  • 7.0.0                                ...           2 years ago
  • 7.0.0-alpha.3                                ...           2 years ago
  • 7.0.0-alpha.2                                ...           2 years ago
  • 7.0.0-alpha.1                                ...           2 years ago
  • 6.6.1-candidate.4                                ...           2 years ago
  • 6.6.1-candidate.3                                ...           2 years ago
  • 6.6.1-candidate.2                                ...           2 years ago
  • 6.6.1-candidate.1                                ...           2 years ago
  • 6.6.1-candidate.0                                ...           2 years ago
  • 6.6.0                                ...           2 years ago
  • 6.6.0-candidate.0                                ...           2 years ago
  • 6.5.0                                ...           2 years ago
  • 6.4.0                                ...           2 years ago
  • 6.3.0                                ...           2 years ago
  • 6.3.0-candidate                                ...           2 years ago
  • 6.2.0                                ...           2 years ago
  • 6.2.0-candidate                                ...           2 years ago
  • 6.1.1                                ...           2 years ago
  • 6.1.1-candidate                                ...           2 years ago
  • 6.1.0-candidate                                ...           2 years ago
  • 6.0.0                                ...           2 years ago
  • 6.0.0-alpha.1                                ...           2 years ago
  • 5.0.0                                ...           2 years ago
  • 5.0.0-candidate                                ...           2 years ago
  • 4.8.1                                ...           2 years ago
  • 4.8.1-candidate                                ...           2 years ago
  • 4.8.0                                ...           2 years ago
  • 4.8.0-candidate3                                ...           2 years ago
  • 4.8.0-candidate2                                ...           2 years ago
  • 4.8.0-candidate                                ...           2 years ago
  • 4.7.1                                ...           3 years ago
  • 4.7.0                                ...           3 years ago
  • 4.7.0-pre                                ...           3 years ago
  • 4.6.0                                ...           3 years ago
  • 4.6.0-candidate                                ...           3 years ago
  • 4.5.0                                ...           3 years ago
  • 4.4.0                                ...           3 years ago
  • 4.3.2                                ...           3 years ago
  • 4.3.1                                ...           3 years ago
  • 4.3.0                                ...           3 years ago
  • 4.2.0                                ...           3 years ago
  • 4.1.0                                ...           3 years ago
  • 4.0.0                                ...           3 years ago
  • 4.0.0-alpha5                                ...           3 years ago
  • 4.0.0-alpha4                                ...           3 years ago
  • 4.0.0-alpha3                                ...           3 years ago
  • 4.0.0-alpha2                                ...           3 years ago
  • 4.0.0-alpha1                                ...           3 years ago
  • 3.32.0                                ...           3 years ago
  • 3.31.0                                ...           3 years ago
  • 3.30.0                                ...           3 years ago
  • 3.29.0                                ...           3 years ago
  • 3.28.0                                ...           3 years ago
  • 3.27.0                                ...           3 years ago
  • 3.26.0                                ...           3 years ago
  • 3.25.0                                ...           3 years ago
  • 3.24.0                                ...           3 years ago
  • 3.23.0                                ...           3 years ago
  • 3.22.2                                ...           3 years ago
  • 3.22.1                                ...           3 years ago
  • 3.22.0                                ...           3 years ago
  • 3.21.1                                ...           3 years ago
  • 3.21.0                                ...           3 years ago
  • 3.20.0                                ...           3 years ago
  • 3.19.0                                ...           3 years ago
  • 3.18.1                                ...           3 years ago
  • 3.18.0                                ...           3 years ago
  • 3.17.1                                ...           3 years ago
  • 3.16.1                                ...           3 years ago
  • 3.16.0                                ...           3 years ago
  • 3.15.0                                ...           3 years ago
  • 3.14.0                                ...           3 years ago
  • 3.13.0                                ...           3 years ago
  • 3.12.0                                ...           3 years ago
  • 3.11.0                                ...           3 years ago
  • 3.10.0                                ...           4 years ago
  • 3.9.1                                ...           4 years ago
  • 3.9.0                                ...           4 years ago
  • 3.8.0                                ...           4 years ago
  • 3.7.2                                ...           4 years ago
  • 3.7.1                                ...           4 years ago
  • 3.7.0                                ...           4 years ago
  • 3.6.0                                ...           4 years ago
  • 3.5.4                                ...           4 years ago
  • 3.5.3                                ...           4 years ago
  • 3.5.2                                ...           4 years ago
  • 3.5.1                                ...           4 years ago
  • 3.5.0                                ...           4 years ago
  • 3.4.5                                ...           4 years ago
  • 3.4.4                                ...           4 years ago
  • 3.4.0                                ...           4 years ago
  • 3.3.1                                ...           4 years ago
  • 3.2.1                                ...           4 years ago
  • 3.1.0                                ...           4 years ago
  • 3.0.4                                ...           4 years ago
  • 3.0.3                                ...           4 years ago
  • 3.0.2                                ...           4 years ago
  • 3.0.1                                ...           4 years ago
  • 3.0.0                                ...           4 years ago
  • 2.3.0                                ...           4 years ago
  • 2.1.1                                ...           4 years ago
  • 1.3.3                                ...           4 years ago
  • 1.3.2                                ...           4 years ago
  • 1.3.1                                ...           4 years ago
  • 1.3.0                                ...           4 years ago
  • 1.2.6                                ...           4 years ago
  • 1.2.5                                ...           4 years ago
  • 1.2.4                                ...           4 years ago
  • 1.2.3                                ...           5 years ago
  • 1.2.2                                ...           5 years ago
  • 1.2.1                                ...           5 years ago
  • 1.2.0                                ...           5 years ago
  • 1.1.3                                ...           5 years ago
  • 1.1.2                                ...           5 years ago
  • 1.1.1                                ...           5 years ago
  • 1.1.0                                ...           5 years ago
  • 1.0.15                                ...           5 years ago
  • 1.0.13                                ...           5 years ago
  • 1.0.12                                ...           5 years ago
  • 1.0.11                                ...           5 years ago
  • 1.0.10                                ...           5 years ago
  • 1.0.9                                ...           5 years ago
  • 1.0.8                                ...           5 years ago
  • 1.0.7                                ...           5 years ago
  • 1.0.6                                ...           5 years ago
  • 1.0.5                                ...           5 years ago
  • 1.0.4                                ...           5 years ago
  • 1.0.3                                ...           5 years ago
  • 1.0.1                                ...           5 years ago
  • 1.0.0                                ...           5 years ago
Downloads
Today 2,206
This Week 226,968
This Month 573,948
Last Day 56,896
Last Week 312,151
Last Month 1,219,819
Dependencies (12)
Dev Dependencies (14)
Dependents (12027)