yargs
Advanced tools
Comparing version 17.7.1 to 17.7.2
@@ -74,5 +74,3 @@ import { isCommandBuilderCallback } from './command.js'; | ||
!this.argsContainKey(args, key, negable)) { | ||
this.completeOptionKey(key, completions, current); | ||
if (negable && !!options.default[key]) | ||
this.completeOptionKey(`no-${key}`, completions, current); | ||
this.completeOptionKey(key, completions, current, negable && !!options.default[key]); | ||
} | ||
@@ -157,13 +155,8 @@ }); | ||
} | ||
completeOptionKey(key, completions, current) { | ||
var _a, _b, _c; | ||
const descs = this.usage.getDescriptions(); | ||
const startsByTwoDashes = (s) => /^--/.test(s); | ||
const isShortOption = (s) => /^[^0-9]$/.test(s); | ||
const dashes = !startsByTwoDashes(current) && isShortOption(key) ? '-' : '--'; | ||
if (!this.zshShell) { | ||
completions.push(dashes + key); | ||
} | ||
else { | ||
const aliasKey = (_a = this === null || this === void 0 ? void 0 : this.aliases) === null || _a === void 0 ? void 0 : _a[key].find(alias => { | ||
completeOptionKey(key, completions, current, negable) { | ||
var _a, _b, _c, _d; | ||
let keyWithDesc = key; | ||
if (this.zshShell) { | ||
const descs = this.usage.getDescriptions(); | ||
const aliasKey = (_b = (_a = this === null || this === void 0 ? void 0 : this.aliases) === null || _a === void 0 ? void 0 : _a[key]) === null || _b === void 0 ? void 0 : _b.find(alias => { | ||
const desc = descs[alias]; | ||
@@ -173,8 +166,14 @@ return typeof desc === 'string' && desc.length > 0; | ||
const descFromAlias = aliasKey ? descs[aliasKey] : undefined; | ||
const desc = (_c = (_b = descs[key]) !== null && _b !== void 0 ? _b : descFromAlias) !== null && _c !== void 0 ? _c : ''; | ||
completions.push(dashes + | ||
`${key.replace(/:/g, '\\:')}:${desc | ||
.replace('__yargsString__:', '') | ||
.replace(/(\r\n|\n|\r)/gm, ' ')}`); | ||
const desc = (_d = (_c = descs[key]) !== null && _c !== void 0 ? _c : descFromAlias) !== null && _d !== void 0 ? _d : ''; | ||
keyWithDesc = `${key.replace(/:/g, '\\:')}:${desc | ||
.replace('__yargsString__:', '') | ||
.replace(/(\r\n|\n|\r)/gm, ' ')}`; | ||
} | ||
const startsByTwoDashes = (s) => /^--/.test(s); | ||
const isShortOption = (s) => /^[^0-9]$/.test(s); | ||
const dashes = !startsByTwoDashes(current) && isShortOption(key) ? '-' : '--'; | ||
completions.push(dashes + keyWithDesc); | ||
if (negable) { | ||
completions.push(dashes + 'no-' + keyWithDesc); | ||
} | ||
} | ||
@@ -181,0 +180,0 @@ customCompletion(args, argv, current, done) { |
{ | ||
"name": "yargs", | ||
"version": "17.7.1", | ||
"version": "17.7.2", | ||
"description": "yargs the modern, pirate-themed, successor to optimist.", | ||
@@ -5,0 +5,0 @@ "main": "./index.cjs", |
Sorry, the diff of this file is not supported yet
292421
5274