@optique/core 1.0.0-dev.886 → 1.0.0-dev.896
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.
- package/dist/completion.cjs +6 -5
- package/dist/completion.js +6 -5
- package/dist/valueparser.cjs +10 -20
- package/dist/valueparser.js +10 -20
- package/package.json +1 -1
package/dist/completion.cjs
CHANGED
|
@@ -5,16 +5,17 @@ const require_message = require('./message.cjs');
|
|
|
5
5
|
* A regular expression pattern for valid program names that can be safely
|
|
6
6
|
* interpolated into shell scripts.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
8
|
+
* The first character must be alphanumeric or underscore. Subsequent
|
|
9
|
+
* characters may also include hyphens and dots:
|
|
9
10
|
* - Letters (a-z, A-Z)
|
|
10
11
|
* - Numbers (0-9)
|
|
11
12
|
* - Underscore (_)
|
|
12
|
-
* - Hyphen (-)
|
|
13
|
-
* - Dot (.)
|
|
13
|
+
* - Hyphen (-) — not as the first character
|
|
14
|
+
* - Dot (.) — not as the first character
|
|
14
15
|
*
|
|
15
16
|
* @internal
|
|
16
17
|
*/
|
|
17
|
-
const SAFE_PROGRAM_NAME_PATTERN = /^[a-zA-Z0-9_.-]
|
|
18
|
+
const SAFE_PROGRAM_NAME_PATTERN = /^[a-zA-Z0-9_][a-zA-Z0-9_.-]*$/;
|
|
18
19
|
/**
|
|
19
20
|
* Validates a program name for safe use in shell scripts.
|
|
20
21
|
*
|
|
@@ -27,7 +28,7 @@ const SAFE_PROGRAM_NAME_PATTERN = /^[a-zA-Z0-9_.-]+$/;
|
|
|
27
28
|
* @internal
|
|
28
29
|
*/
|
|
29
30
|
function validateProgramName(programName) {
|
|
30
|
-
if (!SAFE_PROGRAM_NAME_PATTERN.test(programName)) throw new Error(`Invalid program name for shell completion: "${programName}". Program names must contain only alphanumeric characters, underscores, hyphens, and dots.`);
|
|
31
|
+
if (!SAFE_PROGRAM_NAME_PATTERN.test(programName)) throw new Error(`Invalid program name for shell completion: "${programName}". Program names must start with an alphanumeric character or underscore, and contain only alphanumeric characters, underscores, hyphens, and dots.`);
|
|
31
32
|
}
|
|
32
33
|
/**
|
|
33
34
|
* The Bash shell completion generator.
|
package/dist/completion.js
CHANGED
|
@@ -5,16 +5,17 @@ import { formatMessage } from "./message.js";
|
|
|
5
5
|
* A regular expression pattern for valid program names that can be safely
|
|
6
6
|
* interpolated into shell scripts.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
8
|
+
* The first character must be alphanumeric or underscore. Subsequent
|
|
9
|
+
* characters may also include hyphens and dots:
|
|
9
10
|
* - Letters (a-z, A-Z)
|
|
10
11
|
* - Numbers (0-9)
|
|
11
12
|
* - Underscore (_)
|
|
12
|
-
* - Hyphen (-)
|
|
13
|
-
* - Dot (.)
|
|
13
|
+
* - Hyphen (-) — not as the first character
|
|
14
|
+
* - Dot (.) — not as the first character
|
|
14
15
|
*
|
|
15
16
|
* @internal
|
|
16
17
|
*/
|
|
17
|
-
const SAFE_PROGRAM_NAME_PATTERN = /^[a-zA-Z0-9_.-]
|
|
18
|
+
const SAFE_PROGRAM_NAME_PATTERN = /^[a-zA-Z0-9_][a-zA-Z0-9_.-]*$/;
|
|
18
19
|
/**
|
|
19
20
|
* Validates a program name for safe use in shell scripts.
|
|
20
21
|
*
|
|
@@ -27,7 +28,7 @@ const SAFE_PROGRAM_NAME_PATTERN = /^[a-zA-Z0-9_.-]+$/;
|
|
|
27
28
|
* @internal
|
|
28
29
|
*/
|
|
29
30
|
function validateProgramName(programName) {
|
|
30
|
-
if (!SAFE_PROGRAM_NAME_PATTERN.test(programName)) throw new Error(`Invalid program name for shell completion: "${programName}". Program names must contain only alphanumeric characters, underscores, hyphens, and dots.`);
|
|
31
|
+
if (!SAFE_PROGRAM_NAME_PATTERN.test(programName)) throw new Error(`Invalid program name for shell completion: "${programName}". Program names must start with an alphanumeric character or underscore, and contain only alphanumeric characters, underscores, hyphens, and dots.`);
|
|
31
32
|
}
|
|
32
33
|
/**
|
|
33
34
|
* The Bash shell completion generator.
|
package/dist/valueparser.cjs
CHANGED
|
@@ -317,16 +317,11 @@ function integer(options) {
|
|
|
317
317
|
$mode: "sync",
|
|
318
318
|
metavar: metavar$1,
|
|
319
319
|
parse(input) {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
success: false,
|
|
326
|
-
error: options.errors?.invalidInteger ? typeof options.errors.invalidInteger === "function" ? options.errors.invalidInteger(input) : options.errors.invalidInteger : require_message.message`Expected a valid integer, but got ${input}.`
|
|
327
|
-
};
|
|
328
|
-
throw e;
|
|
329
|
-
}
|
|
320
|
+
if (!input.match(/^-?\d+$/)) return {
|
|
321
|
+
success: false,
|
|
322
|
+
error: options.errors?.invalidInteger ? typeof options.errors.invalidInteger === "function" ? options.errors.invalidInteger(input) : options.errors.invalidInteger : require_message.message`Expected a valid integer, but got ${input}.`
|
|
323
|
+
};
|
|
324
|
+
const value = BigInt(input);
|
|
330
325
|
if (options.min != null && value < options.min) return {
|
|
331
326
|
success: false,
|
|
332
327
|
error: options.errors?.belowMinimum ? typeof options.errors.belowMinimum === "function" ? options.errors.belowMinimum(value, options.min) : options.errors.belowMinimum : require_message.message`Expected a value greater than or equal to ${require_message.text(options.min.toLocaleString("en"))}, but got ${input}.`
|
|
@@ -854,16 +849,11 @@ function port(options) {
|
|
|
854
849
|
$mode: "sync",
|
|
855
850
|
metavar: metavar$1,
|
|
856
851
|
parse(input) {
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
}
|
|
861
|
-
|
|
862
|
-
success: false,
|
|
863
|
-
error: options.errors?.invalidPort ? typeof options.errors.invalidPort === "function" ? options.errors.invalidPort(input) : options.errors.invalidPort : require_message.message`Expected a valid port number, but got ${input}.`
|
|
864
|
-
};
|
|
865
|
-
throw e;
|
|
866
|
-
}
|
|
852
|
+
if (!input.match(/^-?\d+$/)) return {
|
|
853
|
+
success: false,
|
|
854
|
+
error: options.errors?.invalidPort ? typeof options.errors.invalidPort === "function" ? options.errors.invalidPort(input) : options.errors.invalidPort : require_message.message`Expected a valid port number, but got ${input}.`
|
|
855
|
+
};
|
|
856
|
+
const value = BigInt(input);
|
|
867
857
|
if (value < min$1) return {
|
|
868
858
|
success: false,
|
|
869
859
|
error: options.errors?.belowMinimum ? typeof options.errors.belowMinimum === "function" ? options.errors.belowMinimum(value, min$1) : options.errors.belowMinimum : require_message.message`Expected a port number greater than or equal to ${require_message.text(min$1.toLocaleString("en"))}, but got ${input}.`
|
package/dist/valueparser.js
CHANGED
|
@@ -317,16 +317,11 @@ function integer(options) {
|
|
|
317
317
|
$mode: "sync",
|
|
318
318
|
metavar: metavar$1,
|
|
319
319
|
parse(input) {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
success: false,
|
|
326
|
-
error: options.errors?.invalidInteger ? typeof options.errors.invalidInteger === "function" ? options.errors.invalidInteger(input) : options.errors.invalidInteger : message`Expected a valid integer, but got ${input}.`
|
|
327
|
-
};
|
|
328
|
-
throw e;
|
|
329
|
-
}
|
|
320
|
+
if (!input.match(/^-?\d+$/)) return {
|
|
321
|
+
success: false,
|
|
322
|
+
error: options.errors?.invalidInteger ? typeof options.errors.invalidInteger === "function" ? options.errors.invalidInteger(input) : options.errors.invalidInteger : message`Expected a valid integer, but got ${input}.`
|
|
323
|
+
};
|
|
324
|
+
const value = BigInt(input);
|
|
330
325
|
if (options.min != null && value < options.min) return {
|
|
331
326
|
success: false,
|
|
332
327
|
error: options.errors?.belowMinimum ? typeof options.errors.belowMinimum === "function" ? options.errors.belowMinimum(value, options.min) : options.errors.belowMinimum : message`Expected a value greater than or equal to ${text(options.min.toLocaleString("en"))}, but got ${input}.`
|
|
@@ -854,16 +849,11 @@ function port(options) {
|
|
|
854
849
|
$mode: "sync",
|
|
855
850
|
metavar: metavar$1,
|
|
856
851
|
parse(input) {
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
}
|
|
861
|
-
|
|
862
|
-
success: false,
|
|
863
|
-
error: options.errors?.invalidPort ? typeof options.errors.invalidPort === "function" ? options.errors.invalidPort(input) : options.errors.invalidPort : message`Expected a valid port number, but got ${input}.`
|
|
864
|
-
};
|
|
865
|
-
throw e;
|
|
866
|
-
}
|
|
852
|
+
if (!input.match(/^-?\d+$/)) return {
|
|
853
|
+
success: false,
|
|
854
|
+
error: options.errors?.invalidPort ? typeof options.errors.invalidPort === "function" ? options.errors.invalidPort(input) : options.errors.invalidPort : message`Expected a valid port number, but got ${input}.`
|
|
855
|
+
};
|
|
856
|
+
const value = BigInt(input);
|
|
867
857
|
if (value < min$1) return {
|
|
868
858
|
success: false,
|
|
869
859
|
error: options.errors?.belowMinimum ? typeof options.errors.belowMinimum === "function" ? options.errors.belowMinimum(value, min$1) : options.errors.belowMinimum : message`Expected a port number greater than or equal to ${text(min$1.toLocaleString("en"))}, but got ${input}.`
|