Dieses Repository beinhaltet HTML- und Javascript Code zur einer NotizenWebApp auf Basis von Web Storage. Zudem sind Mocha/Chai Tests im Browser enthalten. https://meinenotizen.netlify.app/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 3.6KB

4 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. # yargs-unparser
  2. [![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coverage Status][codecov-image]][codecov-url] [![Dependency status][david-dm-image]][david-dm-url] [![Dev Dependency status][david-dm-dev-image]][david-dm-dev-url] [![Greenkeeper badge][greenkeeper-image]][greenkeeper-url]
  3. [npm-url]:https://npmjs.org/package/yargs-unparser
  4. [npm-image]:http://img.shields.io/npm/v/yargs-unparser.svg
  5. [downloads-image]:http://img.shields.io/npm/dm/yargs-unparser.svg
  6. [travis-url]:https://travis-ci.org/yargs/yargs-unparser
  7. [travis-image]:http://img.shields.io/travis/yargs/yargs-unparser/master.svg
  8. [codecov-url]:https://codecov.io/gh/yargs/yargs-unparser
  9. [codecov-image]:https://img.shields.io/codecov/c/github/yargs/yargs-unparser/master.svg
  10. [david-dm-url]:https://david-dm.org/yargs/yargs-unparser
  11. [david-dm-image]:https://img.shields.io/david/yargs/yargs-unparser.svg
  12. [david-dm-dev-url]:https://david-dm.org/yargs/yargs-unparser?type=dev
  13. [david-dm-dev-image]:https://img.shields.io/david/dev/yargs/yargs-unparser.svg
  14. [greenkeeper-image]:https://badges.greenkeeper.io/yargs/yargs-unparser.svg
  15. [greenkeeper-url]:https://greenkeeper.io
  16. Converts back a `yargs` argv object to its original array form.
  17. Probably the unparser word doesn't even exist, but it sounds nice and goes well with [yargs-parser](https://github.com/yargs/yargs-parser).
  18. The code originally lived in [MOXY](https://github.com/moxystudio)'s GitHub but was later moved here for discoverability.
  19. ## Installation
  20. `$ npm install yargs-unparser`
  21. ## Usage
  22. ```js
  23. const parse = require('yargs-parser');
  24. const unparse = require('yargs-unparser');
  25. const argv = parse(['--no-boolean', '--number', '4', '--string', 'foo'], {
  26. boolean: ['boolean'],
  27. number: ['number'],
  28. string: ['string'],
  29. });
  30. // { boolean: false, number: 4, string: 'foo', _: [] }
  31. const unparsedArgv = unparse(argv);
  32. // ['--no-boolean', '--number', '4', '--string', 'foo'];
  33. ```
  34. The second argument of `unparse` accepts an options object:
  35. - `alias`: The [aliases](https://github.com/yargs/yargs-parser#requireyargs-parserargs-opts) so that duplicate options aren't generated
  36. - `default`: The [default](https://github.com/yargs/yargs-parser#requireyargs-parserargs-opts) values so that the options with default values are omitted
  37. - `command`: The [command](https://github.com/yargs/yargs/blob/master/docs/advanced.md#commands) first argument so that command names and positional arguments are handled correctly
  38. ### Example with `command` options
  39. ```js
  40. const yargs = require('yargs');
  41. const unparse = require('yargs-unparser');
  42. const argv = yargs
  43. .command('my-command <positional>', 'My awesome command', (yargs) =>
  44. yargs
  45. .option('boolean', { type: 'boolean' })
  46. .option('number', { type: 'number' })
  47. .option('string', { type: 'string' })
  48. )
  49. .parse(['my-command', 'hello', '--no-boolean', '--number', '4', '--string', 'foo']);
  50. // { positional: 'hello', boolean: false, number: 4, string: 'foo', _: ['my-command'] }
  51. const unparsedArgv = unparse(argv, {
  52. command: 'my-command <positional>',
  53. });
  54. // ['my-command', 'hello', '--no-boolean', '--number', '4', '--string', 'foo'];
  55. ```
  56. ### Caveats
  57. The returned array can be parsed again by `yargs-parser` using the default configuration. If you used custom configuration that you want `yargs-unparser` to be aware, please fill an [issue](https://github.com/yargs/yargs-unparser/issues).
  58. If you `coerce` in weird ways, things might not work correctly.
  59. ## Tests
  60. `$ npm test`
  61. `$ npm test -- --watch` during development
  62. ## License
  63. [MIT License](http://opensource.org/licenses/MIT)