meow é um auxiliar CLI leve para Node.js que analisa flags e exibe mensagens limpas de --help e --version.
Configuração básica
const meow = require('meow');
const cli = meow(`
Usage:
$ mycli [input] [options]
Options:
--lang, -l Specify preferred language (default: en)
--verbose, -v Enable debug log output
--help, -h Show this help screen
--version Print version and exit
Examples:
$ mycli index.js --lang es
`, {
flags: {
lang: {
type: 'string',
shortFlag: 'l',
default: 'en'
},
verbose: {
type: 'boolean',
shortFlag: 'v'
}
}
});
Acesso à saída analisada
// Parsed flags (automatically normalized to camelCase)
console.log(cli.flags);
// => { lang: 'en', verbose: true }
// Positional non-flag arguments
console.log(cli.input);
// => ['index.js']
// Display help screen and exit
cli.showHelp();
Opções de configuração
| Opção | Tipo | Descrição |
|---|---|---|
flags |
Object | Mapa de nomes de flags e seus tipos (string, boolean, number) |
autoHelp |
Boolean | Interceptar --help automaticamente (padrão: true) |
autoVersion |
Boolean | Interceptar --version automaticamente (padrão: true) |
description |
String | Sobrescrever a descrição do package.json |
allowUnknownFlags |
Boolean | Permitir flags não definidas no esquema de flags |