@optique/core 1.0.0-dev.1279 → 1.0.0-dev.1288
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 +20 -0
- package/dist/facade.js +20 -0
- package/package.json +1 -1
package/dist/facade.cjs
CHANGED
|
@@ -879,24 +879,44 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
|
|
|
879
879
|
const helpOptionArgs = helpTerminatorIndex >= 0 ? args.slice(0, helpTerminatorIndex) : args;
|
|
880
880
|
const hasHelpOption = helpOptionConfig ? completionCommandConfig && completionCommandNames.includes(args[0]) ? args.length >= 2 && helpOptionNames.includes(args[1]) : helpOptionNames.some((n) => helpOptionArgs.includes(n)) : false;
|
|
881
881
|
if (completionCommandConfig && args.length >= 1 && completionCommandNames.includes(args[0]) && !hasHelpOption) return handleCompletion(args.slice(1), programName, parser, completionParsers.completionCommand, stdout, stderr, onCompletionResult, onErrorResult, availableShells, colors, maxWidth, completionCommandNames[0], completionOptionNames[0], false, sectionOrder);
|
|
882
|
+
const hasMetaEntryBefore = (endIndex) => {
|
|
883
|
+
const argsBefore = args.slice(0, endIndex);
|
|
884
|
+
if (helpOptionConfig && helpOptionNames.some((n) => argsBefore.includes(n))) return true;
|
|
885
|
+
if (versionOptionConfig && versionOptionNames.some((n) => argsBefore.includes(n))) return true;
|
|
886
|
+
if (endIndex > 0) {
|
|
887
|
+
if (helpCommandConfig && helpCommandNames.includes(args[0])) return true;
|
|
888
|
+
if (versionCommandConfig && versionCommandNames.includes(args[0])) return true;
|
|
889
|
+
}
|
|
890
|
+
return false;
|
|
891
|
+
};
|
|
892
|
+
let completionOptionIndex = -1;
|
|
882
893
|
if (completionOptionConfig) {
|
|
883
894
|
const loopBound = helpTerminatorIndex >= 0 ? helpTerminatorIndex : args.length;
|
|
884
895
|
for (let i = 0; i < loopBound; i++) {
|
|
885
896
|
const arg = args[i];
|
|
886
897
|
const equalsMatch = completionOptionNames.find((n) => arg.startsWith(n + "="));
|
|
887
898
|
if (equalsMatch) {
|
|
899
|
+
if (hasMetaEntryBefore(i)) {
|
|
900
|
+
completionOptionIndex = i;
|
|
901
|
+
break;
|
|
902
|
+
}
|
|
888
903
|
const shell = arg.slice(equalsMatch.length + 1);
|
|
889
904
|
const completionArgs = args.slice(i + 1);
|
|
890
905
|
return handleCompletion([shell, ...completionArgs], programName, parser, completionParsers.completionOption, stdout, stderr, onCompletionResult, onErrorResult, availableShells, colors, maxWidth, completionCommandNames[0], completionOptionNames[0], true, sectionOrder);
|
|
891
906
|
}
|
|
892
907
|
const exactMatch = completionOptionNames.includes(arg);
|
|
893
908
|
if (exactMatch) {
|
|
909
|
+
if (hasMetaEntryBefore(i)) {
|
|
910
|
+
completionOptionIndex = i;
|
|
911
|
+
break;
|
|
912
|
+
}
|
|
894
913
|
const shell = i + 1 < args.length ? args[i + 1] : "";
|
|
895
914
|
const completionArgs = i + 1 < args.length ? args.slice(i + 2) : [];
|
|
896
915
|
return handleCompletion([shell, ...completionArgs], programName, parser, completionParsers.completionOption, stdout, stderr, onCompletionResult, onErrorResult, availableShells, colors, maxWidth, completionCommandNames[0], completionOptionNames[0], true, sectionOrder);
|
|
897
916
|
}
|
|
898
917
|
}
|
|
899
918
|
}
|
|
919
|
+
if (completionOptionIndex >= 0) args = args.slice(0, completionOptionIndex);
|
|
900
920
|
}
|
|
901
921
|
const augmentedParser = !options.help && !options.version && !options.completion ? parser : combineWithHelpVersion(parser, helpParsers, versionParsers, completionParsers, {
|
|
902
922
|
helpCommandGroup: helpCommandConfig?.group,
|
package/dist/facade.js
CHANGED
|
@@ -879,24 +879,44 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
|
|
|
879
879
|
const helpOptionArgs = helpTerminatorIndex >= 0 ? args.slice(0, helpTerminatorIndex) : args;
|
|
880
880
|
const hasHelpOption = helpOptionConfig ? completionCommandConfig && completionCommandNames.includes(args[0]) ? args.length >= 2 && helpOptionNames.includes(args[1]) : helpOptionNames.some((n) => helpOptionArgs.includes(n)) : false;
|
|
881
881
|
if (completionCommandConfig && args.length >= 1 && completionCommandNames.includes(args[0]) && !hasHelpOption) return handleCompletion(args.slice(1), programName, parser, completionParsers.completionCommand, stdout, stderr, onCompletionResult, onErrorResult, availableShells, colors, maxWidth, completionCommandNames[0], completionOptionNames[0], false, sectionOrder);
|
|
882
|
+
const hasMetaEntryBefore = (endIndex) => {
|
|
883
|
+
const argsBefore = args.slice(0, endIndex);
|
|
884
|
+
if (helpOptionConfig && helpOptionNames.some((n) => argsBefore.includes(n))) return true;
|
|
885
|
+
if (versionOptionConfig && versionOptionNames.some((n) => argsBefore.includes(n))) return true;
|
|
886
|
+
if (endIndex > 0) {
|
|
887
|
+
if (helpCommandConfig && helpCommandNames.includes(args[0])) return true;
|
|
888
|
+
if (versionCommandConfig && versionCommandNames.includes(args[0])) return true;
|
|
889
|
+
}
|
|
890
|
+
return false;
|
|
891
|
+
};
|
|
892
|
+
let completionOptionIndex = -1;
|
|
882
893
|
if (completionOptionConfig) {
|
|
883
894
|
const loopBound = helpTerminatorIndex >= 0 ? helpTerminatorIndex : args.length;
|
|
884
895
|
for (let i = 0; i < loopBound; i++) {
|
|
885
896
|
const arg = args[i];
|
|
886
897
|
const equalsMatch = completionOptionNames.find((n) => arg.startsWith(n + "="));
|
|
887
898
|
if (equalsMatch) {
|
|
899
|
+
if (hasMetaEntryBefore(i)) {
|
|
900
|
+
completionOptionIndex = i;
|
|
901
|
+
break;
|
|
902
|
+
}
|
|
888
903
|
const shell = arg.slice(equalsMatch.length + 1);
|
|
889
904
|
const completionArgs = args.slice(i + 1);
|
|
890
905
|
return handleCompletion([shell, ...completionArgs], programName, parser, completionParsers.completionOption, stdout, stderr, onCompletionResult, onErrorResult, availableShells, colors, maxWidth, completionCommandNames[0], completionOptionNames[0], true, sectionOrder);
|
|
891
906
|
}
|
|
892
907
|
const exactMatch = completionOptionNames.includes(arg);
|
|
893
908
|
if (exactMatch) {
|
|
909
|
+
if (hasMetaEntryBefore(i)) {
|
|
910
|
+
completionOptionIndex = i;
|
|
911
|
+
break;
|
|
912
|
+
}
|
|
894
913
|
const shell = i + 1 < args.length ? args[i + 1] : "";
|
|
895
914
|
const completionArgs = i + 1 < args.length ? args.slice(i + 2) : [];
|
|
896
915
|
return handleCompletion([shell, ...completionArgs], programName, parser, completionParsers.completionOption, stdout, stderr, onCompletionResult, onErrorResult, availableShells, colors, maxWidth, completionCommandNames[0], completionOptionNames[0], true, sectionOrder);
|
|
897
916
|
}
|
|
898
917
|
}
|
|
899
918
|
}
|
|
919
|
+
if (completionOptionIndex >= 0) args = args.slice(0, completionOptionIndex);
|
|
900
920
|
}
|
|
901
921
|
const augmentedParser = !options.help && !options.version && !options.completion ? parser : combineWithHelpVersion(parser, helpParsers, versionParsers, completionParsers, {
|
|
902
922
|
helpCommandGroup: helpCommandConfig?.group,
|