@optique/core 1.0.0-dev.559 → 1.0.0-dev.560

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.
@@ -175,6 +175,16 @@ var WithDefaultError = class extends Error {
175
175
  };
176
176
  function withDefault(parser, defaultValue, options) {
177
177
  const syncParser = parser;
178
+ const getDocDefaultValue = (upperDefaultValue) => {
179
+ if (upperDefaultValue != null) return upperDefaultValue;
180
+ if (options?.message) return void 0;
181
+ if (typeof defaultValue !== "function") return defaultValue;
182
+ try {
183
+ return defaultValue();
184
+ } catch {
185
+ return void 0;
186
+ }
187
+ };
178
188
  function* suggestSync(context, prefix) {
179
189
  const innerState = Array.isArray(context.state) ? context.state[0] : syncParser.initialState;
180
190
  yield* syncParser.suggest({
@@ -318,8 +328,7 @@ function withDefault(parser, defaultValue, options) {
318
328
  kind: "available",
319
329
  state: state.state[0]
320
330
  };
321
- const actualDefaultValue = upperDefaultValue != null ? upperDefaultValue : typeof defaultValue === "function" ? defaultValue() : defaultValue;
322
- const fragments = syncParser.getDocFragments(innerState, actualDefaultValue);
331
+ const fragments = syncParser.getDocFragments(innerState, getDocDefaultValue(upperDefaultValue));
323
332
  if (options?.message) {
324
333
  const modifiedFragments = fragments.fragments.map((fragment) => {
325
334
  if (fragment.type === "entry") return {
package/dist/modifiers.js CHANGED
@@ -175,6 +175,16 @@ var WithDefaultError = class extends Error {
175
175
  };
176
176
  function withDefault(parser, defaultValue, options) {
177
177
  const syncParser = parser;
178
+ const getDocDefaultValue = (upperDefaultValue) => {
179
+ if (upperDefaultValue != null) return upperDefaultValue;
180
+ if (options?.message) return void 0;
181
+ if (typeof defaultValue !== "function") return defaultValue;
182
+ try {
183
+ return defaultValue();
184
+ } catch {
185
+ return void 0;
186
+ }
187
+ };
178
188
  function* suggestSync(context, prefix) {
179
189
  const innerState = Array.isArray(context.state) ? context.state[0] : syncParser.initialState;
180
190
  yield* syncParser.suggest({
@@ -318,8 +328,7 @@ function withDefault(parser, defaultValue, options) {
318
328
  kind: "available",
319
329
  state: state.state[0]
320
330
  };
321
- const actualDefaultValue = upperDefaultValue != null ? upperDefaultValue : typeof defaultValue === "function" ? defaultValue() : defaultValue;
322
- const fragments = syncParser.getDocFragments(innerState, actualDefaultValue);
331
+ const fragments = syncParser.getDocFragments(innerState, getDocDefaultValue(upperDefaultValue));
323
332
  if (options?.message) {
324
333
  const modifiedFragments = fragments.fragments.map((fragment) => {
325
334
  if (fragment.type === "entry") return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/core",
3
- "version": "1.0.0-dev.559+88102fdb",
3
+ "version": "1.0.0-dev.560+6a1e896e",
4
4
  "description": "Type-safe combinatorial command-line interface parser",
5
5
  "keywords": [
6
6
  "CLI",