.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / yargs / README.md
1 # Yargs
2
3 [![Build Status][travis-image]][travis-url]
4 [![Coverage Status][coveralls-image]][coveralls-url]
5 [![NPM version][npm-image]][npm-url]
6 [![Windows Tests][windows-image]][windows-url]
7 [![js-standard-style][standard-image]][standard-url]
8 [![Conventional Commits][conventional-commits-image]][conventional-commits-url]
9 [![Slack][slack-image]][slack-url]
10
11 _Having problems? want to contribute? join our [community slack](http://devtoolscommunity.herokuapp.com)_.
12
13 > Yargs be a node.js library fer hearties tryin' ter parse optstrings.
14
15 <img width="250" src="/yargs-logo.png">
16
17 Yargs helps you build interactive command line tools, by parsing arguments and generating an elegant user interface. It gives you:
18
19 * commands and (grouped) options (`my-program.js serve --port=5000`).
20 * a dynamically generated help menu based on your arguments.
21
22 > <img width="400" src="/screen.png">
23
24 * bash-completion shortcuts for commands and options.
25 * and [tons more](/docs/api.md).
26
27 ## Installation
28
29 ```bash
30 npm i yargs --save
31 ```
32
33 ## Simple Example
34
35 ````javascript
36 #!/usr/bin/env node
37 const argv = require('yargs').argv
38
39 if (argv.ships > 3 && argv.distance < 53.5) {
40   console.log('Plunder more riffiwobbles!')
41 } else {
42   console.log('Retreat from the xupptumblers!')
43 }
44 ````
45
46 ```bash
47 $ ./plunder.js --ships=4 --distance=22
48 Plunder more riffiwobbles!
49
50 $ ./plunder.js --ships 12 --distance 98.7
51 Retreat from the xupptumblers!
52 ```
53
54 ## Complex Example
55
56 ```js
57 #!/usr/bin/env node
58 require('yargs') // eslint-disable-line
59   .command('serve [port]', 'start the server', (yargs) => {
60     yargs
61       .positional('port', {
62         describe: 'port to bind on',
63         default: 5000
64       })
65   }, (argv) => {
66     if (argv.verbose) console.info(`start server on :${argv.port}`)
67     serve(argv.port)
68   })
69   .option('verbose', {
70     alias: 'v',
71     default: false
72   })
73   .argv
74 ```
75
76 Run the example above with `--help` to see the help for the application.
77
78 ## Table of Contents
79
80 * [Yargs' API](/docs/api.md)
81 * [Examples](/docs/examples.md)
82 * [Parsing Tricks](/docs/tricks.md)
83   * [Stop the Parser](/docs/tricks.md#stop)
84   * [Negating Boolean Arguments](/docs/tricks.md#negate)
85   * [Numbers](/docs/tricks.md#numbers)
86   * [Arrays](/docs/tricks.md#arrays)
87   * [Objects](/docs/tricks.md#objects)
88 * [Advanced Topics](/docs/advanced.md)
89   * [Composing Your App Using Commands](/docs/advanced.md#commands)
90   * [Building Configurable CLI Apps](/docs/advanced.md#configuration)
91   * [Customizing Yargs' Parser](/docs/advanced.md#customizing)
92 * [Contributing](/contributing.md)
93
94 [travis-url]: https://travis-ci.org/yargs/yargs
95 [travis-image]: https://img.shields.io/travis/yargs/yargs/master.svg
96 [coveralls-url]: https://coveralls.io/github/yargs/yargs
97 [coveralls-image]: https://img.shields.io/coveralls/yargs/yargs.svg
98 [npm-url]: https://www.npmjs.com/package/yargs
99 [npm-image]: https://img.shields.io/npm/v/yargs.svg
100 [windows-url]: https://ci.appveyor.com/project/bcoe/yargs-ljwvf
101 [windows-image]: https://img.shields.io/appveyor/ci/bcoe/yargs-ljwvf/master.svg?label=Windows%20Tests
102 [standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg
103 [standard-url]: http://standardjs.com/
104 [conventional-commits-image]: https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg
105 [conventional-commits-url]: https://conventionalcommits.org/
106 [slack-image]: http://devtoolscommunity.herokuapp.com/badge.svg
107 [slack-url]: http://devtoolscommunity.herokuapp.com