@beryl-so/cli 0.1.0 → 0.5.0

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.
@@ -58,7 +58,23 @@ export function findCommand(words) {
58
58
  best = { spec, consumed: parts.length };
59
59
  }
60
60
  }
61
- return best;
61
+ if (best)
62
+ return best;
63
+ // A bare group word runs its default subcommand — `beryl tests` is `beryl tests list`.
64
+ // Only when the group is the whole command: `beryl tests bogus` must stay an unknown
65
+ // command, not silently list tests and drop the typo'd subcommand as a stray argument.
66
+ if (words.length === 1) {
67
+ const fallback = groupDefault(words[0]);
68
+ if (fallback)
69
+ return { spec: fallback, consumed: 1 };
70
+ }
71
+ return undefined;
72
+ }
73
+ export function groupDefault(group) {
74
+ return commands.find((spec) => spec.groupDefault && spec.name.split(" ")[0] === group);
75
+ }
76
+ export function groupSummary(specs) {
77
+ return specs.find((s) => s.groupSummary)?.groupSummary;
62
78
  }
63
79
  export function commandGroups() {
64
80
  const groups = new Map();