.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / stylelint / node_modules / meow / readme.md
1 # meow [![Build Status](https://travis-ci.org/sindresorhus/meow.svg?branch=master)](https://travis-ci.org/sindresorhus/meow)
2
3 > CLI app helper
4
5 ![](meow.gif)
6
7
8 ## Features
9
10 - Parses arguments
11 - Converts flags to [camelCase](https://github.com/sindresorhus/camelcase)
12 - Outputs version when `--version`
13 - Outputs description and supplied help text when `--help`
14 - Makes unhandled rejected promises [fail loudly](https://github.com/sindresorhus/loud-rejection) instead of the default silent fail
15 - Sets the process title to the binary name defined in package.json
16
17
18 ## Install
19
20 ```
21 $ npm install meow
22 ```
23
24
25 ## Usage
26
27 ```
28 $ ./foo-app.js unicorns --rainbow
29 ```
30
31 ```js
32 #!/usr/bin/env node
33 'use strict';
34 const meow = require('meow');
35 const foo = require('.');
36
37 const cli = meow(`
38         Usage
39           $ foo <input>
40
41         Options
42           --rainbow, -r  Include a rainbow
43
44         Examples
45           $ foo unicorns --rainbow
46           ðŸŒˆ unicorns ðŸŒˆ
47 `, {
48         flags: {
49                 rainbow: {
50                         type: 'boolean',
51                         alias: 'r'
52                 }
53         }
54 });
55 /*
56 {
57         input: ['unicorns'],
58         flags: {rainbow: true},
59         ...
60 }
61 */
62
63 foo(cli.input[0], cli.flags);
64 ```
65
66
67 ## API
68
69 ### meow(options, [minimistOptions])
70
71 Returns an `Object` with:
72
73 - `input` *(Array)* - Non-flag arguments
74 - `flags` *(Object)* - Flags converted to camelCase
75 - `pkg` *(Object)* - The `package.json` object
76 - `help` *(string)* - The help text used with `--help`
77 - `showHelp([code=2])` *(Function)* - Show the help text and exit with `code`
78 - `showVersion()` *(Function)* - Show the version text and exit
79
80 #### options
81
82 Type: `Object` `Array` `string`
83
84 Can either be a string/array that is the `help` or an options object.
85
86 ##### flags
87
88 Type: `Object`
89
90 Define argument flags.
91
92 The key is the flag name and the value is an object with any of:
93
94 - `type`: Type of value. (Possible values: `string` `boolean`)
95 - `alias`: Usually used to define a short flag alias.
96 - `default`: Default value when the flag is not specified.
97
98 Example:
99
100 ```js
101 flags: {
102         unicorn: {
103                 type: 'string',
104                 alias: 'u',
105                 default: 'rainbow'
106         }
107 }
108 ```
109
110
111 ##### description
112
113 Type: `string` `boolean`<br>
114 Default: The package.json `"description"` property
115
116 Description to show above the help text.
117
118 Set it to `false` to disable it altogether.
119
120 ##### help
121
122 Type: `string` `boolean`
123
124 The help text you want shown.
125
126 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.
127
128 The description will be shown above your help text automatically.
129
130 ##### version
131
132 Type: `string` `boolean`<br>
133 Default: The package.json `"version"` property
134
135 Set a custom version output.
136
137 ##### autoHelp
138
139 Type: `boolean`<br>
140 Default: `true`
141
142 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.
143
144 ##### autoVersion
145
146 Type: `boolean`<br>
147 Default: `true`
148
149 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.
150
151 ##### pkg
152
153 Type: `Object`<br>
154 Default: Closest package.json upwards
155
156 package.json as an `Object`.
157
158 *You most likely don't need this option.*
159
160 ##### argv
161
162 Type: `Array`<br>
163 Default: `process.argv.slice(2)`
164
165 Custom arguments object.
166
167 ##### inferType
168
169 Type: `boolean`<br>
170 Default: `false`
171
172 Infer the argument type.
173
174 By default, the argument `5` in `$ foo 5` becomes a string. Enabling this would infer it as a number.
175
176
177 ## Promises
178
179 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.
180
181
182 ## Tips
183
184 See [`chalk`](https://github.com/chalk/chalk) if you want to colorize the terminal output.
185
186 See [`get-stdin`](https://github.com/sindresorhus/get-stdin) if you want to accept input from stdin.
187
188 See [`conf`](https://github.com/sindresorhus/conf) if you need to persist some data.
189
190 See [`update-notifier`](https://github.com/yeoman/update-notifier) if you want update notifications.
191
192 [More useful CLI utilities…](https://github.com/sindresorhus/awesome-nodejs#command-line-utilities)
193
194
195 ## License
196
197 MIT Â© [Sindre Sorhus](https://sindresorhus.com)