@optique/core 0.7.15 → 0.7.16-dev.389

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.
@@ -1112,10 +1112,17 @@ function group(label, parser) {
1112
1112
  for (const fragment of fragments) if (fragment.type === "entry") allEntries.push(fragment);
1113
1113
  else if (fragment.type === "section") if (fragment.title) titledSections.push(fragment);
1114
1114
  else allEntries.push(...fragment.entries);
1115
- const labeledSection = {
1115
+ const initialFragments = parser.getDocFragments({
1116
+ kind: "available",
1117
+ state: parser.initialState
1118
+ }, void 0);
1119
+ const initialHasCommands = initialFragments.fragments.some((f) => f.type === "entry" && f.term.type === "command" || f.type === "section" && f.entries.some((e) => e.term.type === "command"));
1120
+ const currentHasCommands = allEntries.some((e) => e.term.type === "command");
1121
+ const applyLabel = !initialHasCommands || currentHasCommands;
1122
+ const labeledSection = applyLabel ? {
1116
1123
  title: label,
1117
1124
  entries: allEntries
1118
- };
1125
+ } : { entries: allEntries };
1119
1126
  return {
1120
1127
  description,
1121
1128
  fragments: [...titledSections.map((s) => ({
@@ -1112,10 +1112,17 @@ function group(label, parser) {
1112
1112
  for (const fragment of fragments) if (fragment.type === "entry") allEntries.push(fragment);
1113
1113
  else if (fragment.type === "section") if (fragment.title) titledSections.push(fragment);
1114
1114
  else allEntries.push(...fragment.entries);
1115
- const labeledSection = {
1115
+ const initialFragments = parser.getDocFragments({
1116
+ kind: "available",
1117
+ state: parser.initialState
1118
+ }, void 0);
1119
+ const initialHasCommands = initialFragments.fragments.some((f) => f.type === "entry" && f.term.type === "command" || f.type === "section" && f.entries.some((e) => e.term.type === "command"));
1120
+ const currentHasCommands = allEntries.some((e) => e.term.type === "command");
1121
+ const applyLabel = !initialHasCommands || currentHasCommands;
1122
+ const labeledSection = applyLabel ? {
1116
1123
  title: label,
1117
1124
  entries: allEntries
1118
- };
1125
+ } : { entries: allEntries };
1119
1126
  return {
1120
1127
  description,
1121
1128
  fragments: [...titledSections.map((s) => ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/core",
3
- "version": "0.7.15",
3
+ "version": "0.7.16-dev.389+19027a10",
4
4
  "description": "Type-safe combinatorial command-line interface parser",
5
5
  "keywords": [
6
6
  "CLI",