Skip to content
/ yargs Public
forked from yargs/yargs

yargs the modern, pirate-themed successor to optimist.

License

Notifications You must be signed in to change notification settings

homerr/yargs

This branch is 468 commits behind yargs/yargs:main.

Folders and files

NameName
Last commit message
Last commit date
May 31, 2018
Mar 4, 2018
May 10, 2018
Dec 31, 2017
May 10, 2018
Apr 4, 2017
Oct 12, 2017
Apr 30, 2017
Mar 4, 2018
Apr 10, 2016
Mar 4, 2018
May 1, 2018
Oct 18, 2017
Jan 15, 2016
Aug 17, 2017
May 31, 2018
Jun 12, 2017
Mar 8, 2018
May 10, 2018

Repository files navigation

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

npm i yargs --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

About

yargs the modern, pirate-themed successor to optimist.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 99.8%
  • HTML 0.2%