Socket
Socket
Sign inDemoInstall

meow

Package Overview
Dependencies
58
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 11.0.0 to 12.0.0

source/index.js

121

index.d.ts

@@ -18,8 +18,90 @@ import type {

export type Flag<Type extends FlagType, Default, IsMultiple = false> = {
readonly type?: Type;
readonly alias?: string;
readonly default?: Default;
export type Flag<PrimitiveType extends FlagType, Type, IsMultiple = false> = {
/**
Type of value. (Possible values: `string` `boolean` `number`)
*/
readonly type?: PrimitiveType;
/**
Limit valid values to a predefined set of choices.
@example
```
unicorn: {
isMultiple: true,
choices: ['rainbow', 'cat', 'unicorn']
}
```
*/
readonly choices?: Type extends unknown[] ? Type : Type[];
/**
Default value when the flag is not specified.
@example
```
unicorn: {
type: 'boolean',
default: true
}
```
*/
readonly default?: Type;
/**
A short flag alias.
@example
```
unicorn: {
shortFlag: 'u'
}
```
*/
readonly shortFlag?: string;
/**
Other names for the flag.
@example
```
unicorn: {
aliases: ['unicorns', 'uni']
}
```
*/
readonly aliases?: string[];
/**
Indicates a flag can be set multiple times. Values are turned into an array.
Multiple values are provided by specifying the flag multiple times, for example, `$ foo -u rainbow -u cat`. Space- or comma-separated values [currently *not* supported](https://github.com/sindresorhus/meow/issues/164).
@default false
*/
readonly isMultiple?: IsMultiple;
/**
Determine if the flag is required.
If it's only known at runtime whether the flag is required or not you can pass a Function instead of a boolean, which based on the given flags and other non-flag arguments should decide if the flag is required.
- The first argument is the **flags** object, which contains the flags converted to camel-case excluding aliases.
- The second argument is the **input** string array, which contains the non-flag arguments.
- The function should return a `boolean`, true if the flag is required, otherwise false.
@default false
@example
```
isRequired: (flags, input) => {
if (flags.otherFlag) {
return true;
}
return false;
}
```
*/
readonly isRequired?: boolean | IsRequiredPredicate;
readonly isMultiple?: IsMultiple;
};

@@ -45,8 +127,13 @@

- `type`: Type of value. (Possible values: `string` `boolean` `number`)
- `alias`: Usually used to define a short flag alias.
- `choices`: Limit valid values to a predefined set of choices.
- `default`: Default value when the flag is not specified.
- `isRequired`: Determine if the flag is required.
If it's only known at runtime whether the flag is required or not you can pass a Function instead of a boolean, which based on the given flags and other non-flag arguments should decide if the flag is required.
- `shortFlag`: A short flag alias.
- `aliases`: Other names for the flag.
- `isMultiple`: Indicates a flag can be set multiple times. Values are turned into an array. (Default: false)
Multiple values are provided by specifying the flag multiple times, for example, `$ foo -u rainbow -u cat`. Space- or comma-separated values are *not* supported.
- Multiple values are provided by specifying the flag multiple times, for example, `$ foo -u rainbow -u cat`. Space- or comma-separated values [currently *not* supported](https://github.com/sindresorhus/meow/issues/164).
- `isRequired`: Determine if the flag is required. (Default: false)
- If it's only known at runtime whether the flag is required or not, you can pass a `Function` instead of a `boolean`, which based on the given flags and other non-flag arguments, should decide if the flag is required. Two arguments are passed to the function:
- The first argument is the **flags** object, which contains the flags converted to camel-case excluding aliases.
- The second argument is the **input** string array, which contains the non-flag arguments.
- The function should return a `boolean`, true if the flag is required, otherwise false.

@@ -60,4 +147,6 @@ Note that flags are always defined using a camel-case key (`myKey`), but will match arguments in kebab-case (`--my-key`).

type: 'string',
alias: 'u',
choices: ['rainbow', 'cat', 'unicorn'],
default: ['rainbow', 'cat'],
shortFlag: 'u',
aliases: ['unicorns']
isMultiple: true,

@@ -119,2 +208,4 @@ isRequired: (flags, input) => {

Note: Setting this stops `meow` from finding a package.json.
_You most likely don't need this option._

@@ -172,3 +263,3 @@ */

default: true,
alias: 'r'
shortFlag: 'r'
},

@@ -178,7 +269,7 @@ unicorn: {

default: false,
alias: 'u'
shortFlag: 'u'
},
cake: {
type: 'boolean',
alias: 'c'
shortFlag: 'c'
},

@@ -311,3 +402,3 @@ sparkles: {

type: 'boolean',
alias: 'r'
shortFlag: 'r'
}

@@ -323,3 +414,3 @@ }

foo(cli.input[0], cli.flags);
foo(cli.input.at(0), cli.flags);
```

@@ -326,0 +417,0 @@ */

30

package.json
{
"name": "meow",
"version": "11.0.0",
"version": "12.0.0",
"description": "CLI app helper",

@@ -16,6 +16,6 @@ "license": "MIT",

"types": "./index.d.ts",
"default": "./index.js"
"default": "./source/index.js"
},
"engines": {
"node": ">=14.16"
"node": ">=16.10"
},

@@ -26,3 +26,3 @@ "scripts": {

"files": [
"index.js",
"source",
"index.d.ts"

@@ -53,23 +53,25 @@ ],

"decamelize": "^6.0.0",
"decamelize-keys": "^1.1.0",
"decamelize-keys": "^2.0.1",
"hard-rejection": "^2.1.0",
"minimist-options": "4.1.0",
"normalize-package-data": "^4.0.1",
"normalize-package-data": "^5.0.0",
"read-pkg-up": "^9.1.0",
"redent": "^4.0.0",
"trim-newlines": "^4.0.2",
"type-fest": "^3.1.0",
"trim-newlines": "^5.0.0",
"type-fest": "^3.9.0",
"yargs-parser": "^21.1.1"
},
"devDependencies": {
"ava": "^4.3.3",
"execa": "^6.1.0",
"ava": "^5.2.0",
"common-tags": "^1.8.2",
"execa": "^7.1.1",
"indent-string": "^5.0.0",
"read-pkg": "^7.1.0",
"tsd": "^0.24.1",
"xo": "^0.52.4"
"read-pkg": "^8.0.0",
"tsd": "^0.28.1",
"xo": "^0.54.2"
},
"xo": {
"rules": {
"unicorn/no-process-exit": "off"
"unicorn/no-process-exit": "off",
"unicorn/error-message": "off"
}

@@ -76,0 +78,0 @@ },

@@ -21,11 +21,11 @@ # meow

```sh
npm install meow
```
$ npm install meow
```
## Usage
```sh
./foo-app.js unicorns --rainbow
```
$ ./foo-app.js unicorns --rainbow
```

@@ -52,3 +52,3 @@ ```js

type: 'boolean',
alias: 'r'
shortFlag: 'r'
}

@@ -65,3 +65,3 @@ }

foo(cli.input[0], cli.flags);
foo(cli.input.at(0), cli.flags);
```

@@ -109,4 +109,8 @@

- `type`: Type of value. (Possible values: `string` `boolean` `number`)
- `alias`: Usually used to define a short flag alias.
- `choices`: Limit valid values to a predefined set of choices.
- `default`: Default value when the flag is not specified.
- `shortFlag`: A short flag alias.
- `aliases`: Other names for the flag.
- `isMultiple`: Indicates a flag can be set multiple times. Values are turned into an array. (Default: false)
- Multiple values are provided by specifying the flag multiple times, for example, `$ foo -u rainbow -u cat`. Space- or comma-separated values are [currently *not* supported](https://github.com/sindresorhus/meow/issues/164).
- `isRequired`: Determine if the flag is required. (Default: false)

@@ -117,4 +121,2 @@ - If it's only known at runtime whether the flag is required or not, you can pass a `Function` instead of a `boolean`, which based on the given flags and other non-flag arguments, should decide if the flag is required. Two arguments are passed to the function:

- The function should return a `boolean`, true if the flag is required, otherwise false.
- `isMultiple`: Indicates a flag can be set multiple times. Values are turned into an array. (Default: false)
- Multiple values are provided by specifying the flag multiple times, for example, `$ foo -u rainbow -u cat`. Space- or comma-separated values are [currently *not* supported](https://github.com/sindresorhus/meow/issues/164).

@@ -129,4 +131,6 @@ Note that flags are always defined using a camel-case key (`myKey`), but will match arguments in kebab-case (`--my-key`).

type: 'string',
alias: 'u',
choices: ['rainbow', 'cat', 'unicorn'],
default: ['rainbow', 'cat'],
shortFlag: 'u',
aliases: ['unicorns'],
isMultiple: true,

@@ -186,3 +190,3 @@ isRequired: (flags, input) => {

This option is only considered when there is only one argument in `process.argv`.
This option is only considered when there is only one argument in `process.argv`.

@@ -196,2 +200,4 @@ ##### pkg

Note: Setting this stops `meow` from finding a package.json.
*You most likely don't need this option.*

@@ -253,3 +259,3 @@

default: true,
alias: 'r'
shortFlag: 'r'
},

@@ -259,7 +265,7 @@ unicorn: {

default: false,
alias: 'u'
shortFlag: 'u'
},
cake: {
type: 'boolean',
alias: 'c'
shortFlag: 'c'
},

@@ -317,16 +323,2 @@ sparkles: {

See [`update-notifier`](https://github.com/yeoman/update-notifier) if you want update notifications.
[More useful CLI utilities…](https://github.com/sindresorhus/awesome-nodejs#command-line-utilities)
---
<div align="center">
<b>
<a href="https://tidelift.com/subscription/pkg/npm-meow?utm_source=npm-meow&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
</b>
<br>
<sub>
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
</sub>
</div>
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc