linx-simulator2/node_modules/yargs/README.md

137 lines
3.7 KiB
Markdown
Raw Normal View History

<p align="center">
<img width="250" src="/yargs-logo.png">
</p>
<h1 align="center"> Yargs </h1>
<p align="center">
<b >Yargs be a node.js library fer hearties tryin' ter parse optstrings</b>
</p>
2019-09-18 08:11:16 +00:00
<br>
2019-09-18 08:11:16 +00:00
[![Build Status][travis-image]][travis-url]
[![Coverage Status][coveralls-image]][coveralls-url]
[![NPM version][npm-image]][npm-url]
[![js-standard-style][standard-image]][standard-url]
[![Conventional Commits][conventional-commits-image]][conventional-commits-url]
[![Slack][slack-image]][slack-url]
2019-09-18 08:11:16 +00:00
## Description :
Yargs helps you build interactive command line tools, by parsing arguments and generating an elegant user interface.
2019-09-18 08:11:16 +00:00
It gives you:
2019-09-18 08:11:16 +00:00
* commands and (grouped) options (`my-program.js serve --port=5000`).
* a dynamically generated help menu based on your arguments.
2019-09-18 08:11:16 +00:00
> <img width="400" src="/screen.png">
2019-09-18 08:11:16 +00:00
* bash-completion shortcuts for commands and options.
* and [tons more](/docs/api.md).
2019-09-18 08:11:16 +00:00
## Installation
2019-09-18 08:11:16 +00:00
Stable version:
```bash
npm i yargs
2019-09-18 08:11:16 +00:00
```
Bleeding edge version with the most recent features:
```bash
npm i yargs@next
2019-09-18 08:11:16 +00:00
```
## Usage :
2019-09-18 08:11:16 +00:00
### Simple Example
2019-09-18 08:11:16 +00:00
````javascript
#!/usr/bin/env node
const argv = require('yargs').argv
2019-09-18 08:11:16 +00:00
if (argv.ships > 3 && argv.distance < 53.5) {
console.log('Plunder more riffiwobbles!')
2019-09-18 08:11:16 +00:00
} else {
console.log('Retreat from the xupptumblers!')
2019-09-18 08:11:16 +00:00
}
````
```bash
$ ./plunder.js --ships=4 --distance=22
Plunder more riffiwobbles!
2019-09-18 08:11:16 +00:00
$ ./plunder.js --ships 12 --distance 98.7
Retreat from the xupptumblers!
2019-09-18 08:11:16 +00:00
```
### Complex Example
2019-09-18 08:11:16 +00:00
```javascript
#!/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',
type: 'boolean',
description: 'Run with verbose logging'
2019-09-18 08:11:16 +00:00
})
.argv
```
Run the example above with `--help` to see the help for the application.
2019-09-18 08:11:16 +00:00
## TypeScript
2019-09-18 08:11:16 +00:00
yargs has type definitions at [@types/yargs][type-definitions].
2019-09-18 08:11:16 +00:00
```
npm i @types/yargs --save-dev
2019-09-18 08:11:16 +00:00
```
See usage examples in [docs](/docs/typescript.md).
2019-09-18 08:11:16 +00:00
## Community :
2019-09-18 08:11:16 +00:00
Having problems? want to contribute? join our [community slack](http://devtoolscommunity.herokuapp.com).
2019-09-18 08:11:16 +00:00
## Documentation :
2019-09-18 08:11:16 +00:00
### Table of Contents
2019-09-18 08:11:16 +00:00
* [Yargs' API](/docs/api.md)
* [Examples](/docs/examples.md)
* [Parsing Tricks](/docs/tricks.md)
* [Stop the Parser](/docs/tricks.md#stop)
* [Negating Boolean Arguments](/docs/tricks.md#negate)
* [Numbers](/docs/tricks.md#numbers)
* [Arrays](/docs/tricks.md#arrays)
* [Objects](/docs/tricks.md#objects)
* [Quotes](/docs/tricks.md#quotes)
* [Advanced Topics](/docs/advanced.md)
* [Composing Your App Using Commands](/docs/advanced.md#commands)
* [Building Configurable CLI Apps](/docs/advanced.md#configuration)
* [Customizing Yargs' Parser](/docs/advanced.md#customizing)
* [Contributing](/contributing.md)
2019-09-18 08:11:16 +00:00
[travis-url]: https://travis-ci.org/yargs/yargs
[travis-image]: https://img.shields.io/travis/yargs/yargs/master.svg
[coveralls-url]: https://coveralls.io/github/yargs/yargs
[coveralls-image]: https://img.shields.io/coveralls/yargs/yargs.svg
2019-09-18 08:11:16 +00:00
[npm-url]: https://www.npmjs.com/package/yargs
[npm-image]: https://img.shields.io/npm/v/yargs.svg
[standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg
[standard-url]: http://standardjs.com/
[conventional-commits-image]: https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg
[conventional-commits-url]: https://conventionalcommits.org/
[slack-image]: http://devtoolscommunity.herokuapp.com/badge.svg
[slack-url]: http://devtoolscommunity.herokuapp.com
[type-definitions]: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/yargs