poe-code 3.0.391 → 3.0.392

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.
@@ -3328,11 +3328,21 @@ function findUnknownCommanderCommand(program, argv) {
3328
3328
  commandPath: pathSegments.join(" ")
3329
3329
  };
3330
3330
  }
3331
- if (current.commands.length === 0 || getDefaultCommanderCommandName(current) !== undefined) {
3331
+ if (current.commands.length === 0) {
3332
3332
  return undefined;
3333
3333
  }
3334
3334
  const child = current.commands.find((command) => command.name() === token || command.aliases().includes(token));
3335
3335
  if (child === undefined) {
3336
+ if (getDefaultCommanderCommandName(current) !== undefined) {
3337
+ if (shouldRejectDefaultCommandToken(current, token, pathSegments)) {
3338
+ return {
3339
+ input: token,
3340
+ currentCommand: current,
3341
+ commandPath: pathSegments.join(" ")
3342
+ };
3343
+ }
3344
+ return undefined;
3345
+ }
3336
3346
  return {
3337
3347
  input: token,
3338
3348
  currentCommand: current,
@@ -3344,6 +3354,38 @@ function findUnknownCommanderCommand(program, argv) {
3344
3354
  }
3345
3355
  return undefined;
3346
3356
  }
3357
+ function shouldRejectDefaultCommandToken(command, token, pathSegments) {
3358
+ return (pathSegments.length === 0 &&
3359
+ isBareCommandLikeToken(token) &&
3360
+ hasNonDefaultPublicChildCommand(command));
3361
+ }
3362
+ function hasNonDefaultPublicChildCommand(command) {
3363
+ const defaultName = getDefaultCommanderCommandName(command);
3364
+ return command.commands.some((child) => child.name() !== defaultName &&
3365
+ !isToolcraftHiddenCommander(child) &&
3366
+ !getToolcraftReservedChildNames(command).includes(child.name()));
3367
+ }
3368
+ function isBareCommandLikeToken(token) {
3369
+ if (token.length === 0) {
3370
+ return false;
3371
+ }
3372
+ for (const character of token) {
3373
+ if (!isCommandNameCharacter(character)) {
3374
+ return false;
3375
+ }
3376
+ }
3377
+ return true;
3378
+ }
3379
+ function isCommandNameCharacter(character) {
3380
+ const code = character.codePointAt(0);
3381
+ if (code === undefined) {
3382
+ return false;
3383
+ }
3384
+ const isLowercaseLetter = code >= 97 && code <= 122;
3385
+ const isUppercaseLetter = code >= 65 && code <= 90;
3386
+ const isDigit = code >= 48 && code <= 57;
3387
+ return isLowercaseLetter || isUppercaseLetter || isDigit || character === "-" || character === "_";
3388
+ }
3347
3389
  function getDefaultCommanderCommandName(command) {
3348
3390
  const candidate = command;
3349
3391
  return typeof candidate._defaultCommandName === "string"