poe-code 3.0.391 → 3.0.393

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.
@@ -17624,13 +17624,23 @@ function findUnknownCommanderCommand(program, argv) {
17624
17624
  commandPath: pathSegments.join(" ")
17625
17625
  };
17626
17626
  }
17627
- if (current.commands.length === 0 || getDefaultCommanderCommandName(current) !== void 0) {
17627
+ if (current.commands.length === 0) {
17628
17628
  return void 0;
17629
17629
  }
17630
17630
  const child = current.commands.find(
17631
17631
  (command) => command.name() === token || command.aliases().includes(token)
17632
17632
  );
17633
17633
  if (child === void 0) {
17634
+ if (getDefaultCommanderCommandName(current) !== void 0) {
17635
+ if (shouldRejectDefaultCommandToken(current, token, pathSegments)) {
17636
+ return {
17637
+ input: token,
17638
+ currentCommand: current,
17639
+ commandPath: pathSegments.join(" ")
17640
+ };
17641
+ }
17642
+ return void 0;
17643
+ }
17634
17644
  return {
17635
17645
  input: token,
17636
17646
  currentCommand: current,
@@ -17642,6 +17652,36 @@ function findUnknownCommanderCommand(program, argv) {
17642
17652
  }
17643
17653
  return void 0;
17644
17654
  }
17655
+ function shouldRejectDefaultCommandToken(command, token, pathSegments) {
17656
+ return pathSegments.length === 0 && isBareCommandLikeToken(token) && hasNonDefaultPublicChildCommand(command);
17657
+ }
17658
+ function hasNonDefaultPublicChildCommand(command) {
17659
+ const defaultName = getDefaultCommanderCommandName(command);
17660
+ return command.commands.some(
17661
+ (child) => child.name() !== defaultName && !isToolcraftHiddenCommander(child) && !getToolcraftReservedChildNames(command).includes(child.name())
17662
+ );
17663
+ }
17664
+ function isBareCommandLikeToken(token) {
17665
+ if (token.length === 0) {
17666
+ return false;
17667
+ }
17668
+ for (const character of token) {
17669
+ if (!isCommandNameCharacter(character)) {
17670
+ return false;
17671
+ }
17672
+ }
17673
+ return true;
17674
+ }
17675
+ function isCommandNameCharacter(character) {
17676
+ const code = character.codePointAt(0);
17677
+ if (code === void 0) {
17678
+ return false;
17679
+ }
17680
+ const isLowercaseLetter = code >= 97 && code <= 122;
17681
+ const isUppercaseLetter = code >= 65 && code <= 90;
17682
+ const isDigit = code >= 48 && code <= 57;
17683
+ return isLowercaseLetter || isUppercaseLetter || isDigit || character === "-" || character === "_";
17684
+ }
17645
17685
  function getDefaultCommanderCommandName(command) {
17646
17686
  const candidate = command;
17647
17687
  return typeof candidate._defaultCommandName === "string" ? candidate._defaultCommandName : void 0;