poe-code 3.0.252 → 3.0.253

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.
@@ -1213,14 +1213,29 @@ function createNodeCommand(node, casing, globalLongOptionFlags, execute, presets
1213
1213
  node.aliases.forEach((alias) => group.alias(alias));
1214
1214
  group.addHelpCommand(false);
1215
1215
  addGlobalOptions(group, presetsEnabled, controls);
1216
+ const childNames = new Set(visibleChildren.map((child) => child.name()));
1216
1217
  for (const child of visibleChildren) {
1217
1218
  const isDefaultChild = node.default !== undefined &&
1218
1219
  node.default.scope.includes("cli") &&
1219
1220
  (child.name() === node.default.name || child.aliases().includes(node.default.name));
1220
- group.addCommand(child, isDefaultChild ? { isDefault: true } : undefined);
1221
+ addCommanderChild(group, child, isDefaultChild, childNames);
1221
1222
  }
1222
1223
  return group;
1223
1224
  }
1225
+ function addCommanderChild(parent, child, isDefault, siblingNames) {
1226
+ if (isDefault && child.name().length === 0) {
1227
+ let internalName = "__toolcraft_default__";
1228
+ let suffix = 2;
1229
+ while (siblingNames.has(internalName)) {
1230
+ internalName = `__toolcraft_default_${suffix}`;
1231
+ suffix += 1;
1232
+ }
1233
+ child.name(internalName);
1234
+ parent.addCommand(child, { hidden: true, isDefault: true });
1235
+ return;
1236
+ }
1237
+ parent.addCommand(child, isDefault ? { isDefault: true } : undefined);
1238
+ }
1224
1239
  function addGlobalOptions(command, presetsEnabled, controls) {
1225
1240
  const options = [];
1226
1241
  if (presetsEnabled) {
@@ -2977,6 +2992,9 @@ export async function runCLI(roots, options = {}) {
2977
2992
  errorReportContext = context;
2978
2993
  });
2979
2994
  };
2995
+ const rootChildNames = new Set(root.children
2996
+ .filter((candidate) => isNodeVisibleInScope(candidate, "cli"))
2997
+ .map((candidate) => candidate.name));
2980
2998
  for (const child of root.children) {
2981
2999
  const command = createNodeCommand(child, casing, globalLongOptionFlags, execute, presetsEnabled, controls);
2982
3000
  if (command === null) {
@@ -2985,7 +3003,7 @@ export async function runCLI(roots, options = {}) {
2985
3003
  const isDefaultChild = root.default !== undefined &&
2986
3004
  root.default.scope.includes("cli") &&
2987
3005
  (command.name() === root.default.name || command.aliases().includes(root.default.name));
2988
- program.addCommand(command, isDefaultChild ? { isDefault: true } : undefined);
3006
+ addCommanderChild(program, command, isDefaultChild, rootChildNames);
2989
3007
  }
2990
3008
  configureCommanderSuggestionOutput(program);
2991
3009
  const unknownCommand = findUnknownCommanderCommand(program, process.argv);