@optique/core 1.0.0-dev.1122 → 1.0.0-dev.1129

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.
@@ -194,7 +194,7 @@ function _${programName} () {
194
194
  done < <(${programName} ${escapedArgs} "\${prev[@]}" "$current" 2>/dev/null)
195
195
  }
196
196
 
197
- complete -F _${programName} ${programName}
197
+ complete -F _${programName} -- ${programName}
198
198
  `;
199
199
  },
200
200
  *encodeSuggestions(suggestions) {
@@ -194,7 +194,7 @@ function _${programName} () {
194
194
  done < <(${programName} ${escapedArgs} "\${prev[@]}" "$current" 2>/dev/null)
195
195
  }
196
196
 
197
- complete -F _${programName} ${programName}
197
+ complete -F _${programName} -- ${programName}
198
198
  `;
199
199
  },
200
200
  *encodeSuggestions(suggestions) {
package/dist/facade.cjs CHANGED
@@ -710,6 +710,23 @@ function handleCompletion(completionArgs, programName, parser, completionParser,
710
710
  return callOnCompletion(0);
711
711
  });
712
712
  }
713
+ /**
714
+ * Validates the configured version value.
715
+ *
716
+ * @param value Runtime version value from configuration.
717
+ * @returns The validated version string.
718
+ * @throws {TypeError} If the value is not a string, is empty, or contains
719
+ * ASCII control characters.
720
+ */
721
+ function validateVersionValue(value$1) {
722
+ if (typeof value$1 !== "string") {
723
+ const type = Array.isArray(value$1) ? "array" : typeof value$1;
724
+ throw new TypeError(`Expected version value to be a string, but got ${type}.`);
725
+ }
726
+ if (value$1 === "") throw new TypeError("Version value must not be empty.");
727
+ if (/[\x00-\x1f\x7f]/.test(value$1)) throw new TypeError("Version value must not contain control characters.");
728
+ return value$1;
729
+ }
713
730
  function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsParam) {
714
731
  const isProgram = typeof programNameOrArgs !== "string";
715
732
  let parser;
@@ -746,7 +763,7 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
746
763
  const onHelp = options.help?.onShow ?? (() => ({}));
747
764
  const versionCommandConfig = norm(options.version?.command);
748
765
  const versionOptionConfig = norm(options.version?.option);
749
- const versionValue = options.version?.value ?? "";
766
+ const versionValue = options.version ? validateVersionValue(options.version.value) : void 0;
750
767
  const onVersion = options.version?.onShow ?? (() => ({}));
751
768
  const completionCommandConfig = norm(options.completion?.command);
752
769
  const completionOptionConfig = norm(options.completion?.option);
package/dist/facade.d.cts CHANGED
@@ -272,6 +272,8 @@ interface RunOptions<THelp, TError> {
272
272
  * @param options Configuration options for output formatting and callbacks.
273
273
  * @returns The parsed result value, or the return value of `onHelp`/`onError`
274
274
  * callbacks.
275
+ * @throws {TypeError} If `options.version.value` is not a non-empty string
276
+ * without ASCII control characters.
275
277
  * @throws {RunParserError} When parsing fails and no `onError` callback is
276
278
  * provided.
277
279
  * @since 0.10.0 Added support for {@link Program} objects.
package/dist/facade.d.ts CHANGED
@@ -272,6 +272,8 @@ interface RunOptions<THelp, TError> {
272
272
  * @param options Configuration options for output formatting and callbacks.
273
273
  * @returns The parsed result value, or the return value of `onHelp`/`onError`
274
274
  * callbacks.
275
+ * @throws {TypeError} If `options.version.value` is not a non-empty string
276
+ * without ASCII control characters.
275
277
  * @throws {RunParserError} When parsing fails and no `onError` callback is
276
278
  * provided.
277
279
  * @since 0.10.0 Added support for {@link Program} objects.
package/dist/facade.js CHANGED
@@ -710,6 +710,23 @@ function handleCompletion(completionArgs, programName, parser, completionParser,
710
710
  return callOnCompletion(0);
711
711
  });
712
712
  }
713
+ /**
714
+ * Validates the configured version value.
715
+ *
716
+ * @param value Runtime version value from configuration.
717
+ * @returns The validated version string.
718
+ * @throws {TypeError} If the value is not a string, is empty, or contains
719
+ * ASCII control characters.
720
+ */
721
+ function validateVersionValue(value$1) {
722
+ if (typeof value$1 !== "string") {
723
+ const type = Array.isArray(value$1) ? "array" : typeof value$1;
724
+ throw new TypeError(`Expected version value to be a string, but got ${type}.`);
725
+ }
726
+ if (value$1 === "") throw new TypeError("Version value must not be empty.");
727
+ if (/[\x00-\x1f\x7f]/.test(value$1)) throw new TypeError("Version value must not contain control characters.");
728
+ return value$1;
729
+ }
713
730
  function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsParam) {
714
731
  const isProgram = typeof programNameOrArgs !== "string";
715
732
  let parser;
@@ -746,7 +763,7 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
746
763
  const onHelp = options.help?.onShow ?? (() => ({}));
747
764
  const versionCommandConfig = norm(options.version?.command);
748
765
  const versionOptionConfig = norm(options.version?.option);
749
- const versionValue = options.version?.value ?? "";
766
+ const versionValue = options.version ? validateVersionValue(options.version.value) : void 0;
750
767
  const onVersion = options.version?.onShow ?? (() => ({}));
751
768
  const completionCommandConfig = norm(options.completion?.command);
752
769
  const completionOptionConfig = norm(options.completion?.option);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/core",
3
- "version": "1.0.0-dev.1122+85e536cf",
3
+ "version": "1.0.0-dev.1129+30064af5",
4
4
  "description": "Type-safe combinatorial command-line interface parser",
5
5
  "keywords": [
6
6
  "CLI",