@optique/core 0.7.0-dev.153 → 0.7.0-dev.155
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/facade.cjs +6 -5
- package/dist/facade.js +6 -5
- package/package.json +1 -1
package/dist/facade.cjs
CHANGED
|
@@ -343,7 +343,7 @@ function classifyResult(result, args) {
|
|
|
343
343
|
* Handles shell completion requests.
|
|
344
344
|
* @since 0.6.0
|
|
345
345
|
*/
|
|
346
|
-
function handleCompletion(completionArgs, programName, parser, completionParser, stdout, stderr, onCompletion, onError, availableShells, colors, maxWidth) {
|
|
346
|
+
function handleCompletion(completionArgs, programName, parser, completionParser, stdout, stderr, onCompletion, onError, availableShells, colors, maxWidth, completionMode) {
|
|
347
347
|
const shellName = completionArgs[0] || "";
|
|
348
348
|
const args = completionArgs.slice(1);
|
|
349
349
|
if (!shellName) {
|
|
@@ -375,7 +375,8 @@ function handleCompletion(completionArgs, programName, parser, completionParser,
|
|
|
375
375
|
return onError(1);
|
|
376
376
|
}
|
|
377
377
|
if (args.length === 0) {
|
|
378
|
-
const
|
|
378
|
+
const completionArg = completionMode === "option" ? "--completion" : "completion";
|
|
379
|
+
const script = shell.generateScript(programName, [completionArg, shellName]);
|
|
379
380
|
stdout(script);
|
|
380
381
|
} else {
|
|
381
382
|
const suggestions = require_parser.suggest(parser, args);
|
|
@@ -456,7 +457,7 @@ function run(parser, programName, args, options = {}) {
|
|
|
456
457
|
} : createCompletionParser(completion, programName, availableShells, completionName);
|
|
457
458
|
if (options.completion) {
|
|
458
459
|
const hasHelpOption = args.includes("--help");
|
|
459
|
-
if ((completionMode === "command" || completionMode === "both") && args.length >= 1 && ((completionName === "singular" || completionName === "both" ? args[0] === "completion" : false) || (completionName === "plural" || completionName === "both" ? args[0] === "completions" : false)) && !hasHelpOption) return handleCompletion(args.slice(1), programName, parser, completionParsers.completionCommand, stdout, stderr, onCompletion, onError, availableShells, colors, maxWidth);
|
|
460
|
+
if ((completionMode === "command" || completionMode === "both") && args.length >= 1 && ((completionName === "singular" || completionName === "both" ? args[0] === "completion" : false) || (completionName === "plural" || completionName === "both" ? args[0] === "completions" : false)) && !hasHelpOption) return handleCompletion(args.slice(1), programName, parser, completionParsers.completionCommand, stdout, stderr, onCompletion, onError, availableShells, colors, maxWidth, completionMode);
|
|
460
461
|
if (completionMode === "option" || completionMode === "both") for (let i = 0; i < args.length; i++) {
|
|
461
462
|
const arg = args[i];
|
|
462
463
|
const singularMatch = completionName === "singular" || completionName === "both" ? arg.startsWith("--completion=") : false;
|
|
@@ -464,14 +465,14 @@ function run(parser, programName, args, options = {}) {
|
|
|
464
465
|
if (singularMatch || pluralMatch) {
|
|
465
466
|
const shell = arg.slice(arg.indexOf("=") + 1);
|
|
466
467
|
const completionArgs = args.slice(i + 1);
|
|
467
|
-
return handleCompletion([shell, ...completionArgs], programName, parser, completionParsers.completionCommand, stdout, stderr, onCompletion, onError, availableShells, colors, maxWidth);
|
|
468
|
+
return handleCompletion([shell, ...completionArgs], programName, parser, completionParsers.completionCommand, stdout, stderr, onCompletion, onError, availableShells, colors, maxWidth, completionMode);
|
|
468
469
|
} else {
|
|
469
470
|
const singularMatchExact = completionName === "singular" || completionName === "both" ? arg === "--completion" : false;
|
|
470
471
|
const pluralMatchExact = completionName === "plural" || completionName === "both" ? arg === "--completions" : false;
|
|
471
472
|
if ((singularMatchExact || pluralMatchExact) && i + 1 < args.length) {
|
|
472
473
|
const shell = args[i + 1];
|
|
473
474
|
const completionArgs = args.slice(i + 2);
|
|
474
|
-
return handleCompletion([shell, ...completionArgs], programName, parser, completionParsers.completionCommand, stdout, stderr, onCompletion, onError, availableShells, colors, maxWidth);
|
|
475
|
+
return handleCompletion([shell, ...completionArgs], programName, parser, completionParsers.completionCommand, stdout, stderr, onCompletion, onError, availableShells, colors, maxWidth, completionMode);
|
|
475
476
|
}
|
|
476
477
|
}
|
|
477
478
|
}
|
package/dist/facade.js
CHANGED
|
@@ -343,7 +343,7 @@ function classifyResult(result, args) {
|
|
|
343
343
|
* Handles shell completion requests.
|
|
344
344
|
* @since 0.6.0
|
|
345
345
|
*/
|
|
346
|
-
function handleCompletion(completionArgs, programName, parser, completionParser, stdout, stderr, onCompletion, onError, availableShells, colors, maxWidth) {
|
|
346
|
+
function handleCompletion(completionArgs, programName, parser, completionParser, stdout, stderr, onCompletion, onError, availableShells, colors, maxWidth, completionMode) {
|
|
347
347
|
const shellName = completionArgs[0] || "";
|
|
348
348
|
const args = completionArgs.slice(1);
|
|
349
349
|
if (!shellName) {
|
|
@@ -375,7 +375,8 @@ function handleCompletion(completionArgs, programName, parser, completionParser,
|
|
|
375
375
|
return onError(1);
|
|
376
376
|
}
|
|
377
377
|
if (args.length === 0) {
|
|
378
|
-
const
|
|
378
|
+
const completionArg = completionMode === "option" ? "--completion" : "completion";
|
|
379
|
+
const script = shell.generateScript(programName, [completionArg, shellName]);
|
|
379
380
|
stdout(script);
|
|
380
381
|
} else {
|
|
381
382
|
const suggestions = suggest(parser, args);
|
|
@@ -456,7 +457,7 @@ function run(parser, programName, args, options = {}) {
|
|
|
456
457
|
} : createCompletionParser(completion, programName, availableShells, completionName);
|
|
457
458
|
if (options.completion) {
|
|
458
459
|
const hasHelpOption = args.includes("--help");
|
|
459
|
-
if ((completionMode === "command" || completionMode === "both") && args.length >= 1 && ((completionName === "singular" || completionName === "both" ? args[0] === "completion" : false) || (completionName === "plural" || completionName === "both" ? args[0] === "completions" : false)) && !hasHelpOption) return handleCompletion(args.slice(1), programName, parser, completionParsers.completionCommand, stdout, stderr, onCompletion, onError, availableShells, colors, maxWidth);
|
|
460
|
+
if ((completionMode === "command" || completionMode === "both") && args.length >= 1 && ((completionName === "singular" || completionName === "both" ? args[0] === "completion" : false) || (completionName === "plural" || completionName === "both" ? args[0] === "completions" : false)) && !hasHelpOption) return handleCompletion(args.slice(1), programName, parser, completionParsers.completionCommand, stdout, stderr, onCompletion, onError, availableShells, colors, maxWidth, completionMode);
|
|
460
461
|
if (completionMode === "option" || completionMode === "both") for (let i = 0; i < args.length; i++) {
|
|
461
462
|
const arg = args[i];
|
|
462
463
|
const singularMatch = completionName === "singular" || completionName === "both" ? arg.startsWith("--completion=") : false;
|
|
@@ -464,14 +465,14 @@ function run(parser, programName, args, options = {}) {
|
|
|
464
465
|
if (singularMatch || pluralMatch) {
|
|
465
466
|
const shell = arg.slice(arg.indexOf("=") + 1);
|
|
466
467
|
const completionArgs = args.slice(i + 1);
|
|
467
|
-
return handleCompletion([shell, ...completionArgs], programName, parser, completionParsers.completionCommand, stdout, stderr, onCompletion, onError, availableShells, colors, maxWidth);
|
|
468
|
+
return handleCompletion([shell, ...completionArgs], programName, parser, completionParsers.completionCommand, stdout, stderr, onCompletion, onError, availableShells, colors, maxWidth, completionMode);
|
|
468
469
|
} else {
|
|
469
470
|
const singularMatchExact = completionName === "singular" || completionName === "both" ? arg === "--completion" : false;
|
|
470
471
|
const pluralMatchExact = completionName === "plural" || completionName === "both" ? arg === "--completions" : false;
|
|
471
472
|
if ((singularMatchExact || pluralMatchExact) && i + 1 < args.length) {
|
|
472
473
|
const shell = args[i + 1];
|
|
473
474
|
const completionArgs = args.slice(i + 2);
|
|
474
|
-
return handleCompletion([shell, ...completionArgs], programName, parser, completionParsers.completionCommand, stdout, stderr, onCompletion, onError, availableShells, colors, maxWidth);
|
|
475
|
+
return handleCompletion([shell, ...completionArgs], programName, parser, completionParsers.completionCommand, stdout, stderr, onCompletion, onError, availableShells, colors, maxWidth, completionMode);
|
|
475
476
|
}
|
|
476
477
|
}
|
|
477
478
|
}
|