Simple email application for Android. Original source code: https://framagit.org/dystopia-project/simple-email
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.

197 lines
4.2 KiB

  1. # meow [![Build Status](https://travis-ci.org/sindresorhus/meow.svg?branch=master)](https://travis-ci.org/sindresorhus/meow)
  2. > CLI app helper
  3. ![](meow.gif)
  4. ## Features
  5. - Parses arguments
  6. - Converts flags to [camelCase](https://github.com/sindresorhus/camelcase)
  7. - Outputs version when `--version`
  8. - Outputs description and supplied help text when `--help`
  9. - Makes unhandled rejected promises [fail loudly](https://github.com/sindresorhus/loud-rejection) instead of the default silent fail
  10. - Sets the process title to the binary name defined in package.json
  11. ## Install
  12. ```
  13. $ npm install meow
  14. ```
  15. ## Usage
  16. ```
  17. $ ./foo-app.js unicorns --rainbow
  18. ```
  19. ```js
  20. #!/usr/bin/env node
  21. 'use strict';
  22. const meow = require('meow');
  23. const foo = require('.');
  24. const cli = meow(`
  25. Usage
  26. $ foo <input>
  27. Options
  28. --rainbow, -r Include a rainbow
  29. Examples
  30. $ foo unicorns --rainbow
  31. 🌈 unicorns 🌈
  32. `, {
  33. flags: {
  34. rainbow: {
  35. type: 'boolean',
  36. alias: 'r'
  37. }
  38. }
  39. });
  40. /*
  41. {
  42. input: ['unicorns'],
  43. flags: {rainbow: true},
  44. ...
  45. }
  46. */
  47. foo(cli.input[0], cli.flags);
  48. ```
  49. ## API
  50. ### meow(options, [minimistOptions])
  51. Returns an `Object` with:
  52. - `input` *(Array)* - Non-flag arguments
  53. - `flags` *(Object)* - Flags converted to camelCase
  54. - `pkg` *(Object)* - The `package.json` object
  55. - `help` *(string)* - The help text used with `--help`
  56. - `showHelp([code=2])` *(Function)* - Show the help text and exit with `code`
  57. - `showVersion()` *(Function)* - Show the version text and exit
  58. #### options
  59. Type: `Object` `Array` `string`
  60. Can either be a string/array that is the `help` or an options object.
  61. ##### flags
  62. Type: `Object`
  63. Define argument flags.
  64. The key is the flag name and the value is an object with any of:
  65. - `type`: Type of value. (Possible values: `string` `boolean`)
  66. - `alias`: Usually used to define a short flag alias.
  67. - `default`: Default value when the flag is not specified.
  68. Example:
  69. ```js
  70. flags: {
  71. unicorn: {
  72. type: 'string',
  73. alias: 'u',
  74. default: 'rainbow'
  75. }
  76. }
  77. ```
  78. ##### description
  79. Type: `string` `boolean`<br>
  80. Default: The package.json `"description"` property
  81. Description to show above the help text.
  82. Set it to `false` to disable it altogether.
  83. ##### help
  84. Type: `string` `boolean`
  85. The help text you want shown.
  86. The input is reindented and starting/ending newlines are trimmed which means you can use a [template literal](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/template_strings) without having to care about using the correct amount of indent.
  87. The description will be shown above your help text automatically.
  88. ##### version
  89. Type: `string` `boolean`<br>
  90. Default: The package.json `"version"` property
  91. Set a custom version output.
  92. ##### autoHelp
  93. Type: `boolean`<br>
  94. Default: `true`
  95. Automatically show the help text when the `--help` flag is present. Useful to set this value to `false` when a CLI manages child CLIs with their own help text.
  96. ##### autoVersion
  97. Type: `boolean`<br>
  98. Default: `true`
  99. Automatically show the version text when the `--version` flag is present. Useful to set this value to `false` when a CLI manages child CLIs with their own version text.
  100. ##### pkg
  101. Type: `Object`<br>
  102. Default: Closest package.json upwards
  103. package.json as an `Object`.
  104. *You most likely don't need this option.*
  105. ##### argv
  106. Type: `Array`<br>
  107. Default: `process.argv.slice(2)`
  108. Custom arguments object.
  109. ##### inferType
  110. Type: `boolean`<br>
  111. Default: `false`
  112. Infer the argument type.
  113. By default, the argument `5` in `$ foo 5` becomes a string. Enabling this would infer it as a number.
  114. ## Promises
  115. Meow will make unhandled rejected promises [fail loudly](https://github.com/sindresorhus/loud-rejection) instead of the default silent fail. Meaning you don't have to manually `.catch()` promises used in your CLI.
  116. ## Tips
  117. See [`chalk`](https://github.com/chalk/chalk) if you want to colorize the terminal output.
  118. See [`get-stdin`](https://github.com/sindresorhus/get-stdin) if you want to accept input from stdin.
  119. See [`conf`](https://github.com/sindresorhus/conf) if you need to persist some data.
  120. See [`update-notifier`](https://github.com/yeoman/update-notifier) if you want update notifications.
  121. [More useful CLI utilities…](https://github.com/sindresorhus/awesome-nodejs#command-line-utilities)
  122. ## License
  123. MIT © [Sindre Sorhus](https://sindresorhus.com)