• Home
Name
Date
Size
#Lines
LOC

..--

lib/12-May-2024-1,8051,397

locales/12-May-2024-919895

node_modules/12-May-2024-1,9001,402

CHANGELOG.mdD12-May-202490 KiB1,407864

LICENSED12-May-20241.2 KiB2318

README.mdD12-May-20243.7 KiB137107

index.jsD12-May-20241,020 4025

package.jsonD12-May-20242.6 KiB111110

yargs.jsD12-May-202438.4 KiB1,253951

README.md

1 <p align="center">
2   <img width="250" src="/yargs-logo.png">
3 </p>
4 <h1 align="center"> Yargs </h1>
5 <p align="center">
6   <b >Yargs be a node.js library fer hearties tryin' ter parse optstrings</b>
7 </p>
8 
9 <br>
10 
11 [![Build Status][travis-image]][travis-url]
12 [![Coverage Status][coveralls-image]][coveralls-url]
13 [![NPM version][npm-image]][npm-url]
14 [![js-standard-style][standard-image]][standard-url]
15 [![Conventional Commits][conventional-commits-image]][conventional-commits-url]
16 [![Slack][slack-image]][slack-url]
17 
18 ## Description :
19 Yargs helps you build interactive command line tools, by parsing arguments and generating an elegant user interface.
20 
21 It gives you:
22 
23 * commands and (grouped) options (`my-program.js serve --port=5000`).
24 * a dynamically generated help menu based on your arguments.
25 
26 > <img width="400" src="/screen.png">
27 
28 * bash-completion shortcuts for commands and options.
29 * and [tons more](/docs/api.md).
30 
31 ## Installation
32 
33 Stable version:
34 ```bash
35 npm i yargs
36 ```
37 
38 Bleeding edge version with the most recent features:
39 ```bash
40 npm i yargs@next
41 ```
42 
43 ## Usage :
44 
45 ### Simple Example
46 
47 ````javascript
48 #!/usr/bin/env node
49 const argv = require('yargs').argv
50 
51 if (argv.ships > 3 && argv.distance < 53.5) {
52   console.log('Plunder more riffiwobbles!')
53 } else {
54   console.log('Retreat from the xupptumblers!')
55 }
56 ````
57 
58 ```bash
59 $ ./plunder.js --ships=4 --distance=22
60 Plunder more riffiwobbles!
61 
62 $ ./plunder.js --ships 12 --distance 98.7
63 Retreat from the xupptumblers!
64 ```
65 
66 ### Complex Example
67 
68 ```javascript
69 #!/usr/bin/env node
70 require('yargs') // eslint-disable-line
71   .command('serve [port]', 'start the server', (yargs) => {
72     yargs
73       .positional('port', {
74         describe: 'port to bind on',
75         default: 5000
76       })
77   }, (argv) => {
78     if (argv.verbose) console.info(`start server on :${argv.port}`)
79     serve(argv.port)
80   })
81   .option('verbose', {
82     alias: 'v',
83     type: 'boolean',
84     description: 'Run with verbose logging'
85   })
86   .argv
87 ```
88 
89 Run the example above with `--help` to see the help for the application.
90 
91 ## TypeScript
92 
93 yargs has type definitions at [@types/yargs][type-definitions].
94 
95 ```
96 npm i @types/yargs --save-dev
97 ```
98 
99 See usage examples in [docs](/docs/typescript.md).
100 
101 ## Community :
102 
103 Having problems? want to contribute? join our [community slack](http://devtoolscommunity.herokuapp.com).
104 
105 ## Documentation :
106 
107 ### Table of Contents
108 
109 * [Yargs' API](/docs/api.md)
110 * [Examples](/docs/examples.md)
111 * [Parsing Tricks](/docs/tricks.md)
112   * [Stop the Parser](/docs/tricks.md#stop)
113   * [Negating Boolean Arguments](/docs/tricks.md#negate)
114   * [Numbers](/docs/tricks.md#numbers)
115   * [Arrays](/docs/tricks.md#arrays)
116   * [Objects](/docs/tricks.md#objects)
117   * [Quotes](/docs/tricks.md#quotes)
118 * [Advanced Topics](/docs/advanced.md)
119   * [Composing Your App Using Commands](/docs/advanced.md#commands)
120   * [Building Configurable CLI Apps](/docs/advanced.md#configuration)
121   * [Customizing Yargs' Parser](/docs/advanced.md#customizing)
122 * [Contributing](/contributing.md)
123 
124 [travis-url]: https://travis-ci.org/yargs/yargs
125 [travis-image]: https://img.shields.io/travis/yargs/yargs/master.svg
126 [coveralls-url]: https://coveralls.io/github/yargs/yargs
127 [coveralls-image]: https://img.shields.io/coveralls/yargs/yargs.svg
128 [npm-url]: https://www.npmjs.com/package/yargs
129 [npm-image]: https://img.shields.io/npm/v/yargs.svg
130 [standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg
131 [standard-url]: http://standardjs.com/
132 [conventional-commits-image]: https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg
133 [conventional-commits-url]: https://conventionalcommits.org/
134 [slack-image]: http://devtoolscommunity.herokuapp.com/badge.svg
135 [slack-url]: http://devtoolscommunity.herokuapp.com
136 [type-definitions]: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/yargs
137