@optique/core 1.0.2-dev.1987 → 1.0.4

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.
@@ -237,7 +237,7 @@ function* getSuggestionsWithDependency(valueParser, prefix, dependencyRegistry,
237
237
  * Internal sync helper for option suggest functionality.
238
238
  * @internal
239
239
  */
240
- function* suggestOptionSync(optionNames$1, valueParser, hidden, context, prefix) {
240
+ function* suggestOptionSync(optionNames$1, valueParser, hidden, description, context, prefix) {
241
241
  if (hidden) return;
242
242
  const equalsIndex = prefix.indexOf("=");
243
243
  if (equalsIndex >= 0) {
@@ -265,7 +265,8 @@ function* suggestOptionSync(optionNames$1, valueParser, hidden, context, prefix)
265
265
  if (prefix === "-" && optionName$1.length !== 2) continue;
266
266
  yield {
267
267
  kind: "literal",
268
- text: optionName$1
268
+ text: optionName$1,
269
+ ...description && { description }
269
270
  };
270
271
  }
271
272
  }
@@ -321,7 +322,7 @@ async function* getSuggestionsWithDependencyAsync(valueParser, prefix, dependenc
321
322
  * Internal async helper for option suggest functionality.
322
323
  * @internal
323
324
  */
324
- async function* suggestOptionAsync(optionNames$1, valueParser, hidden, context, prefix) {
325
+ async function* suggestOptionAsync(optionNames$1, valueParser, hidden, description, context, prefix) {
325
326
  if (hidden) return;
326
327
  const equalsIndex = prefix.indexOf("=");
327
328
  if (equalsIndex >= 0) {
@@ -349,7 +350,8 @@ async function* suggestOptionAsync(optionNames$1, valueParser, hidden, context,
349
350
  if (prefix === "-" && optionName$1.length !== 2) continue;
350
351
  yield {
351
352
  kind: "literal",
352
- text: optionName$1
353
+ text: optionName$1,
354
+ ...description && { description }
353
355
  };
354
356
  }
355
357
  }
@@ -615,8 +617,8 @@ function option(...args) {
615
617
  return require_mode_dispatch.dispatchByMode(mode, completeSync, completeAsync);
616
618
  },
617
619
  suggest(context, prefix) {
618
- if (isAsync) return suggestOptionAsync(optionNames$1, valueParser, require_usage.isSuggestionHidden(options.hidden), context, prefix);
619
- return suggestOptionSync(optionNames$1, valueParser, require_usage.isSuggestionHidden(options.hidden), context, prefix);
620
+ if (isAsync) return suggestOptionAsync(optionNames$1, valueParser, require_usage.isSuggestionHidden(options.hidden), options.description, context, prefix);
621
+ return suggestOptionSync(optionNames$1, valueParser, require_usage.isSuggestionHidden(options.hidden), options.description, context, prefix);
620
622
  },
621
623
  getDocFragments(_state, defaultValue) {
622
624
  if (require_usage.isDocHidden(options.hidden)) return {
@@ -893,7 +895,8 @@ function flag(...args) {
893
895
  if (prefix === "-" && optionName$1.length !== 2) continue;
894
896
  suggestions.push({
895
897
  kind: "literal",
896
- text: optionName$1
898
+ text: optionName$1,
899
+ ...options.description && { description: options.description }
897
900
  });
898
901
  }
899
902
  }
@@ -1157,11 +1160,14 @@ function* suggestCommandSync(context, prefix, name, parser, options) {
1157
1160
  if (require_usage.isSuggestionHidden(options.hidden)) return;
1158
1161
  const state = normalizeCommandState(context.state);
1159
1162
  if (state === void 0) {
1160
- if (name.startsWith(prefix)) yield {
1161
- kind: "literal",
1162
- text: name,
1163
- ...options.description && { description: options.description }
1164
- };
1163
+ if (name.startsWith(prefix)) {
1164
+ const description = options.brief ?? options.description;
1165
+ yield {
1166
+ kind: "literal",
1167
+ text: name,
1168
+ ...description && { description }
1169
+ };
1170
+ }
1165
1171
  } else if (state[0] === "matched") yield* parser.suggest(require_execution_context.withChildContext(context, name, getCommandChildState(context.state, parser.initialState, parser), parser.usage), prefix);
1166
1172
  else if (state[0] === "parsing") yield* parser.suggest(require_execution_context.withChildContext(context, name, getCommandChildState(context.state, state[1], parser), parser.usage), prefix);
1167
1173
  }
@@ -1169,11 +1175,14 @@ async function* suggestCommandAsync(context, prefix, name, parser, options) {
1169
1175
  if (require_usage.isSuggestionHidden(options.hidden)) return;
1170
1176
  const state = normalizeCommandState(context.state);
1171
1177
  if (state === void 0) {
1172
- if (name.startsWith(prefix)) yield {
1173
- kind: "literal",
1174
- text: name,
1175
- ...options.description && { description: options.description }
1176
- };
1178
+ if (name.startsWith(prefix)) {
1179
+ const description = options.brief ?? options.description;
1180
+ yield {
1181
+ kind: "literal",
1182
+ text: name,
1183
+ ...description && { description }
1184
+ };
1185
+ }
1177
1186
  } else if (state[0] === "matched") {
1178
1187
  const suggestions = parser.suggest(require_execution_context.withChildContext(context, name, getCommandChildState(context.state, parser.initialState, parser), parser.usage), prefix);
1179
1188
  for await (const s of suggestions) yield s;
@@ -237,7 +237,7 @@ function* getSuggestionsWithDependency(valueParser, prefix, dependencyRegistry,
237
237
  * Internal sync helper for option suggest functionality.
238
238
  * @internal
239
239
  */
240
- function* suggestOptionSync(optionNames$1, valueParser, hidden, context, prefix) {
240
+ function* suggestOptionSync(optionNames$1, valueParser, hidden, description, context, prefix) {
241
241
  if (hidden) return;
242
242
  const equalsIndex = prefix.indexOf("=");
243
243
  if (equalsIndex >= 0) {
@@ -265,7 +265,8 @@ function* suggestOptionSync(optionNames$1, valueParser, hidden, context, prefix)
265
265
  if (prefix === "-" && optionName$1.length !== 2) continue;
266
266
  yield {
267
267
  kind: "literal",
268
- text: optionName$1
268
+ text: optionName$1,
269
+ ...description && { description }
269
270
  };
270
271
  }
271
272
  }
@@ -321,7 +322,7 @@ async function* getSuggestionsWithDependencyAsync(valueParser, prefix, dependenc
321
322
  * Internal async helper for option suggest functionality.
322
323
  * @internal
323
324
  */
324
- async function* suggestOptionAsync(optionNames$1, valueParser, hidden, context, prefix) {
325
+ async function* suggestOptionAsync(optionNames$1, valueParser, hidden, description, context, prefix) {
325
326
  if (hidden) return;
326
327
  const equalsIndex = prefix.indexOf("=");
327
328
  if (equalsIndex >= 0) {
@@ -349,7 +350,8 @@ async function* suggestOptionAsync(optionNames$1, valueParser, hidden, context,
349
350
  if (prefix === "-" && optionName$1.length !== 2) continue;
350
351
  yield {
351
352
  kind: "literal",
352
- text: optionName$1
353
+ text: optionName$1,
354
+ ...description && { description }
353
355
  };
354
356
  }
355
357
  }
@@ -615,8 +617,8 @@ function option(...args) {
615
617
  return dispatchByMode(mode, completeSync, completeAsync);
616
618
  },
617
619
  suggest(context, prefix) {
618
- if (isAsync) return suggestOptionAsync(optionNames$1, valueParser, isSuggestionHidden(options.hidden), context, prefix);
619
- return suggestOptionSync(optionNames$1, valueParser, isSuggestionHidden(options.hidden), context, prefix);
620
+ if (isAsync) return suggestOptionAsync(optionNames$1, valueParser, isSuggestionHidden(options.hidden), options.description, context, prefix);
621
+ return suggestOptionSync(optionNames$1, valueParser, isSuggestionHidden(options.hidden), options.description, context, prefix);
620
622
  },
621
623
  getDocFragments(_state, defaultValue) {
622
624
  if (isDocHidden(options.hidden)) return {
@@ -893,7 +895,8 @@ function flag(...args) {
893
895
  if (prefix === "-" && optionName$1.length !== 2) continue;
894
896
  suggestions.push({
895
897
  kind: "literal",
896
- text: optionName$1
898
+ text: optionName$1,
899
+ ...options.description && { description: options.description }
897
900
  });
898
901
  }
899
902
  }
@@ -1157,11 +1160,14 @@ function* suggestCommandSync(context, prefix, name, parser, options) {
1157
1160
  if (isSuggestionHidden(options.hidden)) return;
1158
1161
  const state = normalizeCommandState(context.state);
1159
1162
  if (state === void 0) {
1160
- if (name.startsWith(prefix)) yield {
1161
- kind: "literal",
1162
- text: name,
1163
- ...options.description && { description: options.description }
1164
- };
1163
+ if (name.startsWith(prefix)) {
1164
+ const description = options.brief ?? options.description;
1165
+ yield {
1166
+ kind: "literal",
1167
+ text: name,
1168
+ ...description && { description }
1169
+ };
1170
+ }
1165
1171
  } else if (state[0] === "matched") yield* parser.suggest(withChildContext(context, name, getCommandChildState(context.state, parser.initialState, parser), parser.usage), prefix);
1166
1172
  else if (state[0] === "parsing") yield* parser.suggest(withChildContext(context, name, getCommandChildState(context.state, state[1], parser), parser.usage), prefix);
1167
1173
  }
@@ -1169,11 +1175,14 @@ async function* suggestCommandAsync(context, prefix, name, parser, options) {
1169
1175
  if (isSuggestionHidden(options.hidden)) return;
1170
1176
  const state = normalizeCommandState(context.state);
1171
1177
  if (state === void 0) {
1172
- if (name.startsWith(prefix)) yield {
1173
- kind: "literal",
1174
- text: name,
1175
- ...options.description && { description: options.description }
1176
- };
1178
+ if (name.startsWith(prefix)) {
1179
+ const description = options.brief ?? options.description;
1180
+ yield {
1181
+ kind: "literal",
1182
+ text: name,
1183
+ ...description && { description }
1184
+ };
1185
+ }
1177
1186
  } else if (state[0] === "matched") {
1178
1187
  const suggestions = parser.suggest(withChildContext(context, name, getCommandChildState(context.state, parser.initialState, parser), parser.usage), prefix);
1179
1188
  for await (const s of suggestions) yield s;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/core",
3
- "version": "1.0.2-dev.1987+5b69ea74",
3
+ "version": "1.0.4",
4
4
  "description": "Type-safe combinatorial command-line interface parser",
5
5
  "keywords": [
6
6
  "CLI",