- Timestamp:
- 11/25/21 22:08:24 (3 years ago)
- Branches:
- master
- Children:
- 8d391a1
- Parents:
- 59329aa
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trip-planner-front/node_modules/yargs-parser/README.md
r59329aa re29cc2e 1 1 # yargs-parser 2 2 3 ![ci](https://github.com/yargs/yargs-parser/workflows/ci/badge.svg) 3 [![Build Status](https://travis-ci.org/yargs/yargs-parser.svg)](https://travis-ci.org/yargs/yargs-parser) 4 [![Coverage Status](https://coveralls.io/repos/yargs/yargs-parser/badge.svg?branch=)](https://coveralls.io/r/yargs/yargs-parser?branch=master) 4 5 [![NPM version](https://img.shields.io/npm/v/yargs-parser.svg)](https://www.npmjs.com/package/yargs-parser) 5 [![ Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org)6 ![nycrc config on GitHub](https://img.shields.io/nycrc/yargs/yargs-parser) 6 [![Standard Version](https://img.shields.io/badge/release-standard%20version-brightgreen.svg)](https://github.com/conventional-changelog/standard-version) 7 7 8 8 9 The mighty option parser used by [yargs](https://github.com/yargs/yargs). … … 10 11 visit the [yargs website](http://yargs.js.org/) for more examples, and thorough usage instructions. 11 12 12 <img width="250" src="https://raw.githubusercontent.com/yargs/yargs-parser/ma in/yargs-logo.png">13 <img width="250" src="https://raw.githubusercontent.com/yargs/yargs-parser/master/yargs-logo.png"> 13 14 14 15 ## Example … … 19 20 20 21 ```js 21 constargv = require('yargs-parser')(process.argv.slice(2))22 var argv = require('yargs-parser')(process.argv.slice(2)) 22 23 console.log(argv) 23 24 ``` 24 25 25 ``` console26 $node example.js --foo=33 --bar hello26 ```sh 27 node example.js --foo=33 --bar hello 27 28 { _: [], foo: 33, bar: 'hello' } 28 29 ``` … … 31 32 32 33 ```js 33 const argv = require('yargs-parser')('--foo=99 --bar=33')34 var argv = require('./')('--foo=99 --bar=33') 34 35 console.log(argv) 35 36 ``` 36 37 37 ``` console38 ```sh 38 39 { _: [], foo: 99, bar: 33 } 39 40 ``` … … 42 43 43 44 ```js 44 constparse = require('yargs-parser')45 var parse = require('yargs-parser') 45 46 parse(['-f', 11, '--zoom', 55].join(' ')) // <-- array to string 46 47 parse(['-f', 11, '--zoom', 55].map(String)) // <-- array of strings 47 48 ``` 48 49 49 ## Deno Example50 51 As of `v19` `yargs-parser` supports [Deno](https://github.com/denoland/deno):52 53 ```typescript54 import parser from "https://deno.land/x/yargs_parser/deno.ts";55 56 const argv = parser('--foo=99 --bar=9987930', {57 string: ['bar']58 })59 console.log(argv)60 ```61 62 ## ESM Example63 64 As of `v19` `yargs-parser` supports ESM (_both in Node.js and in the browser_):65 66 **Node.js:**67 68 ```js69 import parser from 'yargs-parser'70 71 const argv = parser('--foo=99 --bar=9987930', {72 string: ['bar']73 })74 console.log(argv)75 ```76 77 **Browsers:**78 79 ```html80 <!doctype html>81 <body>82 <script type="module">83 import parser from "https://unpkg.com/yargs-parser@19.0.0/browser.js";84 85 const argv = parser('--foo=99 --bar=9987930', {86 string: ['bar']87 })88 console.log(argv)89 </script>90 </body>91 ```92 93 50 ## API 94 51 95 ### parser(args, opts={})52 ### require('yargs-parser')(args, opts={}) 96 53 97 54 Parses command line arguments returning a simple mapping of keys and values. … … 143 100 * `key/value`: key value pairs for each argument and their aliases. 144 101 * `_`: an array representing the positional arguments. 145 * [optional] `--`: an array with arguments after the end-of-options flag `--`.146 102 * `error`: populated with an error object if an exception occurred during parsing. 147 103 * `aliases`: the inferred list of aliases built by combining lists in `opts.alias`. 148 * `newAliases`: any new aliases added via camel-case expansion: 149 * `boolean`: `{ fooBar: true }` 150 * `defaulted`: any new argument created by `opts.default`, no aliases included. 151 * `boolean`: `{ foo: true }` 152 * `configuration`: given by default settings and `opts.configuration`. 104 * `newAliases`: any new aliases added via camel-case expansion. 105 * `configuration`: the configuration loaded from the `yargs` stanza in package.json. 153 106 154 107 <a name="configuration"></a> … … 175 128 Should a group of short-options be treated as boolean flags? 176 129 177 ``` console178 $node example.js -abc130 ```sh 131 node example.js -abc 179 132 { _: [], a: true, b: true, c: true } 180 133 ``` … … 182 135 _if disabled:_ 183 136 184 ``` console185 $node example.js -abc137 ```sh 138 node example.js -abc 186 139 { _: [], abc: true } 187 140 ``` … … 194 147 Should hyphenated arguments be expanded into camel-case aliases? 195 148 196 ``` console197 $node example.js --foo-bar149 ```sh 150 node example.js --foo-bar 198 151 { _: [], 'foo-bar': true, fooBar: true } 199 152 ``` … … 201 154 _if disabled:_ 202 155 203 ``` console204 $node example.js --foo-bar156 ```sh 157 node example.js --foo-bar 205 158 { _: [], 'foo-bar': true } 206 159 ``` … … 213 166 Should keys that contain `.` be treated as objects? 214 167 215 ``` console216 $node example.js --foo.bar168 ```sh 169 node example.js --foo.bar 217 170 { _: [], foo: { bar: true } } 218 171 ``` … … 220 173 _if disabled:_ 221 174 222 ``` console223 $node example.js --foo.bar175 ```sh 176 node example.js --foo.bar 224 177 { _: [], "foo.bar": true } 225 178 ``` … … 232 185 Should keys that look like numbers be treated as such? 233 186 234 ``` console235 $node example.js --foo=99.3187 ```sh 188 node example.js --foo=99.3 236 189 { _: [], foo: 99.3 } 237 190 ``` … … 239 192 _if disabled:_ 240 193 241 ``` console242 $node example.js --foo=99.3194 ```sh 195 node example.js --foo=99.3 243 196 { _: [], foo: "99.3" } 244 197 ``` 245 198 246 ### parse positional numbers247 248 * default: `true`249 * key: `parse-positional-numbers`250 251 Should positional keys that look like numbers be treated as such.252 253 ```console254 $ node example.js 99.3255 { _: [99.3] }256 ```257 258 _if disabled:_259 260 ```console261 $ node example.js 99.3262 { _: ['99.3'] }263 ```264 265 199 ### boolean negation 266 200 … … 270 204 Should variables prefixed with `--no` be treated as negations? 271 205 272 ``` console273 $node example.js --no-foo206 ```sh 207 node example.js --no-foo 274 208 { _: [], foo: false } 275 209 ``` … … 277 211 _if disabled:_ 278 212 279 ``` console280 $node example.js --no-foo213 ```sh 214 node example.js --no-foo 281 215 { _: [], "no-foo": true } 282 216 ``` … … 297 231 Should arguments be coerced into an array when duplicated: 298 232 299 ``` console300 $node example.js -x 1 -x 2233 ```sh 234 node example.js -x 1 -x 2 301 235 { _: [], x: [1, 2] } 302 236 ``` … … 304 238 _if disabled:_ 305 239 306 ``` console307 $node example.js -x 1 -x 2240 ```sh 241 node example.js -x 1 -x 2 308 242 { _: [], x: 2 } 309 243 ``` … … 316 250 Should array arguments be coerced into a single array when duplicated: 317 251 318 ``` console319 $node example.js -x 1 2 -x 3 4252 ```sh 253 node example.js -x 1 2 -x 3 4 320 254 { _: [], x: [1, 2, 3, 4] } 321 255 ``` … … 323 257 _if disabled:_ 324 258 325 ``` console326 $node example.js -x 1 2 -x 3 4259 ```sh 260 node example.js -x 1 2 -x 3 4 327 261 { _: [], x: [[1, 2], [3, 4]] } 328 262 ``` 329 330 ### greedy arrays331 332 * default: `true`333 * key: `greedy-arrays`334 335 Should arrays consume more than one positional argument following their flag.336 337 ```console338 $ node example --arr 1 2339 { _: [], arr: [1, 2] }340 ```341 342 _if disabled:_343 344 ```console345 $ node example --arr 1 2346 { _: [2], arr: [1] }347 ```348 349 **Note: in `v18.0.0` we are considering defaulting greedy arrays to `false`.**350 351 ### nargs eats options352 353 * default: `false`354 * key: `nargs-eats-options`355 356 Should nargs consume dash options as well as positional arguments.357 263 358 264 ### negation prefix … … 363 269 The prefix to use for negated boolean variables. 364 270 365 ``` console366 $node example.js --no-foo271 ```sh 272 node example.js --no-foo 367 273 { _: [], foo: false } 368 274 ``` … … 370 276 _if set to `quux`:_ 371 277 372 ``` console373 $node example.js --quuxfoo278 ```sh 279 node example.js --quuxfoo 374 280 { _: [], foo: false } 375 281 ``` … … 384 290 _If disabled:_ 385 291 386 ``` console387 $node example.js a -b -- x y292 ```sh 293 node example.js a -b -- x y 388 294 { _: [ 'a', 'x', 'y' ], b: true } 389 295 ``` … … 391 297 _If enabled:_ 392 298 393 ``` console394 $node example.js a -b -- x y299 ```sh 300 node example.js a -b -- x y 395 301 { _: [ 'a' ], '--': [ 'x', 'y' ], b: true } 396 302 ``` … … 405 311 _If disabled:_ 406 312 407 ``` console408 $node example.js -a 1 -c 2313 ```sh 314 node example.js -a 1 -c 2 409 315 { _: [], a: 1, c: 2 } 410 316 ``` … … 412 318 _If enabled:_ 413 319 414 ``` console415 $node example.js -a 1 -c 2320 ```sh 321 node example.js -a 1 -c 2 416 322 { _: [], a: 1, b: undefined, c: 2 } 417 323 ``` … … 426 332 _If disabled:_ 427 333 428 ``` console429 $node example.js -a run b -x y334 ```sh 335 node example.js -a run b -x y 430 336 { _: [ 'b' ], a: 'run', x: 'y' } 431 337 ``` … … 433 339 _If enabled:_ 434 340 435 ``` console436 $node example.js -a run b -x y341 ```sh 342 node example.js -a run b -x y 437 343 { _: [ 'b', '-x', 'y' ], a: 'run' } 438 344 ``` … … 447 353 _If disabled:_ 448 354 449 ``` console450 $node example.js --test-field 1355 ```sh 356 node example.js --test-field 1 451 357 { _: [], 'test-field': 1, testField: 1, 'test-alias': 1, testAlias: 1 } 452 358 ``` … … 454 360 _If enabled:_ 455 361 456 ``` console457 $node example.js --test-field 1362 ```sh 363 node example.js --test-field 1 458 364 { _: [], 'test-field': 1, testField: 1 } 459 365 ``` … … 465 371 466 372 Should dashed keys be removed before returning results? This option has no effect if 467 `camel-case-ex pansion` is disabled.468 469 _If disabled:_ 470 471 ``` console472 $node example.js --test-field 1373 `camel-case-exansion` is disabled. 374 375 _If disabled:_ 376 377 ```sh 378 node example.js --test-field 1 473 379 { _: [], 'test-field': 1, testField: 1 } 474 380 ``` … … 476 382 _If enabled:_ 477 383 478 ``` console479 $node example.js --test-field 1384 ```sh 385 node example.js --test-field 1 480 386 { _: [], testField: 1 } 481 387 ``` 482 483 ### unknown options as args484 485 * default: `false`486 * key: `unknown-options-as-args`487 488 Should unknown options be treated like regular arguments? An unknown option is one that is not489 configured in `opts`.490 491 _If disabled_492 493 ```console494 $ node example.js --unknown-option --known-option 2 --string-option --unknown-option2495 { _: [], unknownOption: true, knownOption: 2, stringOption: '', unknownOption2: true }496 ```497 498 _If enabled_499 500 ```console501 $ node example.js --unknown-option --known-option 2 --string-option --unknown-option2502 { _: ['--unknown-option'], knownOption: 2, stringOption: '--unknown-option2' }503 ```504 505 ## Supported Node.js Versions506 507 Libraries in this ecosystem make a best effort to track508 [Node.js' release schedule](https://nodejs.org/en/about/releases/). Here's [a509 post on why we think this is important](https://medium.com/the-node-js-collection/maintainers-should-consider-following-node-js-release-schedule-ab08ed4de71a).510 388 511 389 ## Special Thanks
Note:
See TracChangeset
for help on using the changeset viewer.