| { | ||
| "Commands:": "Polecenia:", | ||
| "Options:": "Opcje:", | ||
| "Examples:": "Przykłady:", | ||
| "boolean": "boolean", | ||
| "count": "ilość", | ||
| "string": "ciąg znaków", | ||
| "array": "tablica", | ||
| "required": "wymagany", | ||
| "default:": "domyślny:", | ||
| "choices:": "dostępne:", | ||
| "generated-value": "wygenerowana-wartość", | ||
| "Not enough non-option arguments: got %s, need at least %s": "Niewystarczająca ilość argumentów: otrzymano %s, wymagane co najmniej %s", | ||
| "Too many non-option arguments: got %s, maximum of %s": "Zbyt duża ilość argumentów: otrzymano %s, wymagane co najwyżej %s", | ||
| "Missing argument value: %s": { | ||
| "one": "Brak wartości dla argumentu: %s", | ||
| "other": "Brak wartości dla argumentów: %s" | ||
| }, | ||
| "Missing required argument: %s": { | ||
| "one": "Brak wymaganego argumentu: %s", | ||
| "other": "Brak wymaganych argumentów: %s" | ||
| }, | ||
| "Unknown argument: %s": { | ||
| "one": "Nieznany argument: %s", | ||
| "other": "Nieznane argumenty: %s" | ||
| }, | ||
| "Invalid values:": "Nieprawidłowe wartości:", | ||
| "Argument: %s, Given: %s, Choices: %s": "Argument: %s, Otrzymano: %s, Dostępne: %s", | ||
| "Argument check failed: %s": "Weryfikacja argumentów nie powiodła się: %s", | ||
| "Implications failed:": "Założenia nie zostały spełnione:", | ||
| "Not enough arguments following: %s": "Niewystarczająca ilość argumentów następujących po: %s", | ||
| "Invalid JSON config file: %s": "Nieprawidłowy plik konfiguracyjny JSON: %s", | ||
| "Path to JSON config file": "Ścieżka do pliku konfiguracyjnego JSON", | ||
| "Show help": "Pokaż pomoc", | ||
| "Show version number": "Pokaż numer wersji" | ||
| } |
| { | ||
| "Commands:": "Comandos:", | ||
| "Options:": "Opções:", | ||
| "Examples:": "Exemplos:", | ||
| "boolean": "boolean", | ||
| "count": "contagem", | ||
| "string": "string", | ||
| "array": "array", | ||
| "required": "obrigatório", | ||
| "default:": "padrão:", | ||
| "choices:": "opções:", | ||
| "generated-value": "valor-gerado", | ||
| "Not enough non-option arguments: got %s, need at least %s": "Argumentos insuficientes: Argumento %s, necessário pelo menos %s", | ||
| "Too many non-option arguments: got %s, maximum of %s": "Excesso de argumentos: recebido %s, máximo de %s", | ||
| "Missing argument value: %s": { | ||
| "one": "Falta valor de argumento: %s", | ||
| "other": "Falta valores de argumento: %s" | ||
| }, | ||
| "Missing required argument: %s": { | ||
| "one": "Falta argumento obrigatório: %s", | ||
| "other": "Faltando argumentos obrigatórios: %s" | ||
| }, | ||
| "Unknown argument: %s": { | ||
| "one": "Argumento desconhecido: %s", | ||
| "other": "Argumentos desconhecidos: %s" | ||
| }, | ||
| "Invalid values:": "Valores inválidos:", | ||
| "Argument: %s, Given: %s, Choices: %s": "Argumento: %s, Dado: %s, Opções: %s", | ||
| "Argument check failed: %s": "Verificação de argumento falhou: %s", | ||
| "Implications failed:": "Implicações falharam:", | ||
| "Not enough arguments following: %s": "Argumentos insuficientes a seguir: %s", | ||
| "Invalid JSON config file: %s": "Arquivo JSON de configuração inválido: %s", | ||
| "Path to JSON config file": "Caminho para o arquivo JSON de configuração", | ||
| "Show help": "Exibe ajuda", | ||
| "Show version number": "Exibe a versão" | ||
| } |
+6
-0
| ## Change Log | ||
| ### v3.30.0 (2015/11/13 16:29 +07:00) | ||
| - [#293](https://github.com/bcoe/yargs/pull/293) Polish language support (@kamilogorek). | ||
| - [#291](https://github.com/bcoe/yargs/pull/291) fix edge-cases with `.alias()` (@bcoe) | ||
| - [#289](https://github.com/bcoe/yargs/pull/289) group options in custom groups (@bcoe) | ||
| ### v3.29.0 (2015/10/16 21:51 +07:00) | ||
@@ -4,0 +10,0 @@ |
+30
-1
@@ -169,3 +169,21 @@ var assert = require('assert') | ||
| } else { | ||
| options.alias[x] = (options.alias[x] || []).concat(y) | ||
| // perhaps 'x' is already an alias in another list? | ||
| // if so we should append to x's list. | ||
| var aliases = null | ||
| Object.keys(options.alias).forEach(function (key) { | ||
| if (~options.alias[key].indexOf(x)) aliases = options.alias[key] | ||
| }) | ||
| if (aliases) { // x was an alias itself. | ||
| aliases.push(y) | ||
| } else { // x is a new alias key. | ||
| options.alias[x] = (options.alias[x] || []).concat(y) | ||
| } | ||
| // wait! perhaps we've created two lists of aliases | ||
| // that reference each other? | ||
| if (options.alias[y]) { | ||
| Array.prototype.push.apply((options.alias[x] || aliases), options.alias[y]) | ||
| delete options.alias[y] | ||
| } | ||
| } | ||
@@ -286,2 +304,4 @@ return self | ||
| self.choices(key, opt.choices) | ||
| } if ('group' in opt) { | ||
| self.group(key, opt.group) | ||
| } if (opt.boolean || opt.type === 'boolean') { | ||
@@ -318,2 +338,11 @@ self.boolean(key) | ||
| var groups = {} | ||
| self.group = function (opts, groupName) { | ||
| groups[groupName] = (groups[groupName] || []).concat(opts) | ||
| return self | ||
| } | ||
| self.getGroups = function () { | ||
| return groups | ||
| } | ||
| self.wrap = function (cols) { | ||
@@ -320,0 +349,0 @@ usage.wrap(cols) |
+54
-13
@@ -104,2 +104,3 @@ // this file handles outputting usage instructions, | ||
| var defaultGroup = 'Options:' | ||
| self.help = function () { | ||
@@ -109,2 +110,3 @@ normalizeAliases() | ||
| var demanded = yargs.getDemanded() | ||
| var groups = yargs.getGroups() | ||
| var options = yargs.getOptions() | ||
@@ -146,3 +148,4 @@ var keys = Object.keys( | ||
| // the options table. | ||
| // perform some cleanup on the keys array, making it | ||
| // only include top-level keys not their aliases. | ||
| var aliasKeys = (Object.keys(options.alias) || []) | ||
@@ -157,16 +160,35 @@ .concat(Object.keys(yargs.parsed.newAliases) || []) | ||
| var switches = keys.reduce(function (acc, key) { | ||
| acc[key] = [ key ].concat(options.alias[key] || []) | ||
| .map(function (sw) { | ||
| return (sw.length > 1 ? '--' : '-') + sw | ||
| // populate 'Options:' group with any keys that have not | ||
| // explicitly had a group set. | ||
| if (!groups[defaultGroup]) groups[defaultGroup] = [] | ||
| addUngroupedKeys(keys, options.alias, groups) | ||
| // display 'Options:' table along with any custom tables: | ||
| Object.keys(groups).forEach(function (groupName) { | ||
| if (!groups[groupName].length) return | ||
| ui.div(__(groupName)) | ||
| // if we've grouped the key 'f', but 'f' aliases 'foobar', | ||
| // normalizedKeys should contain only 'foobar'. | ||
| var normalizedKeys = groups[groupName].map(function (key) { | ||
| if (~aliasKeys.indexOf(key)) return key | ||
| for (var i = 0, aliasKey; (aliasKey = aliasKeys[i]) !== undefined; i++) { | ||
| if (~(options.alias[aliasKey] || []).indexOf(key)) return aliasKey | ||
| } | ||
| return key | ||
| }) | ||
| .join(', ') | ||
| return acc | ||
| }, {}) | ||
| // actually generate the switches string --foo, -f, --bar. | ||
| var switches = normalizedKeys.reduce(function (acc, key) { | ||
| acc[key] = [ key ].concat(options.alias[key] || []) | ||
| .map(function (sw) { | ||
| return (sw.length > 1 ? '--' : '-') + sw | ||
| }) | ||
| .join(', ') | ||
| if (keys.length) { | ||
| ui.div(__('Options:')) | ||
| return acc | ||
| }, {}) | ||
| keys.forEach(function (key) { | ||
| normalizedKeys.forEach(function (key) { | ||
| var kswitch = switches[key] | ||
@@ -202,3 +224,3 @@ var desc = descriptions[key] || '' | ||
| ui.div() | ||
| } | ||
| }) | ||
@@ -268,3 +290,2 @@ // describe some common use-cases for your application. | ||
| if (demanded[alias]) yargs.demand(key, demanded[alias].msg) | ||
| // type messages. | ||
@@ -280,2 +301,22 @@ if (~options.boolean.indexOf(alias)) yargs.boolean(key) | ||
| // given a set of keys, place any keys that are | ||
| // ungrouped under the 'Options:' grouping. | ||
| function addUngroupedKeys (keys, aliases, groups) { | ||
| var groupedKeys = [] | ||
| var toCheck = null | ||
| Object.keys(groups).forEach(function (group) { | ||
| groupedKeys = groupedKeys.concat(groups[group]) | ||
| }) | ||
| keys.forEach(function (key) { | ||
| toCheck = [key].concat(aliases[key]) | ||
| if (!toCheck.some(function (k) { | ||
| return groupedKeys.indexOf(k) !== -1 | ||
| })) { | ||
| groups[defaultGroup].push(key) | ||
| } | ||
| }) | ||
| return groupedKeys | ||
| } | ||
| self.showHelp = function (level) { | ||
@@ -282,0 +323,0 @@ level = level || 'error' |
+3
-3
| { | ||
| "name": "yargs", | ||
| "version": "3.29.0", | ||
| "version": "3.30.0", | ||
| "description": "Light-weight option parsing with an argv hash. No optstrings attached.", | ||
@@ -16,3 +16,3 @@ "main": "./index.js", | ||
| "cliui": "^3.0.3", | ||
| "decamelize": "^1.0.0", | ||
| "decamelize": "^1.1.1", | ||
| "os-locale": "^1.4.0", | ||
@@ -23,3 +23,3 @@ "window-size": "^0.1.2", | ||
| "devDependencies": { | ||
| "chai": "^3.3.0", | ||
| "chai": "^3.4.1", | ||
| "chalk": "^1.1.1", | ||
@@ -26,0 +26,0 @@ "coveralls": "^2.11.4", |
+25
-2
@@ -652,2 +652,23 @@ yargs | ||
| <a name="group"></a>.group(key(s), groupName) | ||
| -------------------- | ||
| Given a key, or an array of keys, places options under an alternative heading | ||
| when displaying usage instructions, e.g., | ||
| ```js | ||
| var yargs = require('yargs')(['--help']) | ||
| .help('help') | ||
| .group('batman', 'Heroes:') | ||
| .describe('batman', "world's greatest detective") | ||
| .wrap(null) | ||
| .argv | ||
| ``` | ||
| *** | ||
| Heroes: | ||
| --batman world's greatest detective | ||
| Options: | ||
| --help Show help [boolean] | ||
| .help([option, [description]]) | ||
@@ -739,2 +760,3 @@ ------------------------------ | ||
| * **pt:** Portuguese. | ||
| * **pt_BR:** Brazilian Portuguese. | ||
| * **zh:** Chinese. | ||
@@ -831,2 +853,3 @@ * **pirate:** American Pirate. | ||
| - `desc`/`describe`/`description`: string, the option description for help content, see [`describe()`](#describe) | ||
| - `group`: string, when displaying usage instructions place the option under an alternative group heading, see [`group()`](#group) | ||
| - `nargs`: number, specify how many arguments should be consumed for the option, see [`nargs()`](#nargs) | ||
@@ -1109,3 +1132,3 @@ - `requiresArg`: boolean, require the option be specified with a value, see [`requiresArg()`](#requiresArg) | ||
| With [npm](http://github.com/isaacs/npm), just do: | ||
| With [npm](https://github.com/npm/npm), just do: | ||
@@ -1136,5 +1159,5 @@ npm install yargs | ||
| [coveralls-image]: https://img.shields.io/coveralls/bcoe/yargs.svg | ||
| [npm-url]: https://npmjs.org/package/yargs | ||
| [npm-url]: https://www.npmjs.com/package/yargs | ||
| [npm-image]: https://img.shields.io/npm/v/yargs.svg | ||
| [windows-url]: https://ci.appveyor.com/project/bcoe/yargs | ||
| [windows-image]: https://img.shields.io/appveyor/ci/bcoe/yargs/master.svg?label=Windows%20Tests |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
140328
4.88%20
11.11%1883
7.72%1159
2.02%8
-11.11%Updated