@optique/core 0.9.1 → 0.9.2

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.
@@ -840,21 +840,23 @@ function command(name, parser, options = {}) {
840
840
  return suggestCommandSync(context, prefix, name, parser, options);
841
841
  },
842
842
  getDocFragments(state, defaultValue) {
843
- if (options.hidden) return {
844
- fragments: [],
845
- description: options.description
846
- };
847
- if (state.kind === "unavailable" || typeof state.state === "undefined") return {
848
- description: options.description,
849
- fragments: [{
850
- type: "entry",
851
- term: {
852
- type: "command",
853
- name
854
- },
855
- description: options.brief ?? options.description
856
- }]
857
- };
843
+ if (state.kind === "unavailable" || typeof state.state === "undefined") {
844
+ if (options.hidden) return {
845
+ fragments: [],
846
+ description: options.description
847
+ };
848
+ return {
849
+ description: options.description,
850
+ fragments: [{
851
+ type: "entry",
852
+ term: {
853
+ type: "command",
854
+ name
855
+ },
856
+ description: options.brief ?? options.description
857
+ }]
858
+ };
859
+ }
858
860
  const innerState = state.state[0] === "parsing" ? {
859
861
  kind: "available",
860
862
  state: state.state[1]
@@ -840,21 +840,23 @@ function command(name, parser, options = {}) {
840
840
  return suggestCommandSync(context, prefix, name, parser, options);
841
841
  },
842
842
  getDocFragments(state, defaultValue) {
843
- if (options.hidden) return {
844
- fragments: [],
845
- description: options.description
846
- };
847
- if (state.kind === "unavailable" || typeof state.state === "undefined") return {
848
- description: options.description,
849
- fragments: [{
850
- type: "entry",
851
- term: {
852
- type: "command",
853
- name
854
- },
855
- description: options.brief ?? options.description
856
- }]
857
- };
843
+ if (state.kind === "unavailable" || typeof state.state === "undefined") {
844
+ if (options.hidden) return {
845
+ fragments: [],
846
+ description: options.description
847
+ };
848
+ return {
849
+ description: options.description,
850
+ fragments: [{
851
+ type: "entry",
852
+ term: {
853
+ type: "command",
854
+ name
855
+ },
856
+ description: options.brief ?? options.description
857
+ }]
858
+ };
859
+ }
858
860
  const innerState = state.state[0] === "parsing" ? {
859
861
  kind: "available",
860
862
  state: state.state[1]
package/dist/usage.cjs CHANGED
@@ -123,6 +123,8 @@ function formatUsage(programName, usage, options = {}) {
123
123
  if (usage.length > 0 && usage.slice(0, -1).every((t) => t.type === "command") && lastTerm.type === "exclusive" && lastTerm.terms.every((t) => t.length > 0 && (t[0].type === "command" || t[0].type === "option" || t[0].type === "argument" || t[0].type === "optional" && t[0].terms.length === 1 && (t[0].terms[0].type === "command" || t[0].terms[0].type === "option" || t[0].terms[0].type === "argument")))) {
124
124
  const lines = [];
125
125
  for (let command of lastTerm.terms) {
126
+ const firstTerm = command[0];
127
+ if (firstTerm?.type === "command" && firstTerm.hidden) continue;
126
128
  if (usage.length > 1) command = [...usage.slice(0, -1), ...command];
127
129
  lines.push(formatUsage(programName, command, options));
128
130
  }
package/dist/usage.js CHANGED
@@ -122,6 +122,8 @@ function formatUsage(programName, usage, options = {}) {
122
122
  if (usage.length > 0 && usage.slice(0, -1).every((t) => t.type === "command") && lastTerm.type === "exclusive" && lastTerm.terms.every((t) => t.length > 0 && (t[0].type === "command" || t[0].type === "option" || t[0].type === "argument" || t[0].type === "optional" && t[0].terms.length === 1 && (t[0].terms[0].type === "command" || t[0].terms[0].type === "option" || t[0].terms[0].type === "argument")))) {
123
123
  const lines = [];
124
124
  for (let command of lastTerm.terms) {
125
+ const firstTerm = command[0];
126
+ if (firstTerm?.type === "command" && firstTerm.hidden) continue;
125
127
  if (usage.length > 1) command = [...usage.slice(0, -1), ...command];
126
128
  lines.push(formatUsage(programName, command, options));
127
129
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/core",
3
- "version": "0.9.1",
3
+ "version": "0.9.2",
4
4
  "description": "Type-safe combinatorial command-line interface parser",
5
5
  "keywords": [
6
6
  "CLI",