@clerc/core 1.0.0-beta.10 → 1.0.0-beta.12
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/index.d.ts +38 -2
- package/dist/index.js +2 -2
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { ErrorHandler as ErrorHandler$1 } from "lite-emit";
|
|
2
2
|
|
|
3
|
+
//#region rolldown:runtime
|
|
4
|
+
//#endregion
|
|
5
|
+
//#region ../parser/src/errors.d.ts
|
|
6
|
+
declare class InvalidSchemaError extends Error {
|
|
7
|
+
constructor(message: string);
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
3
10
|
//#region ../parser/src/flag-types.d.ts
|
|
4
|
-
|
|
5
11
|
/**
|
|
6
12
|
* Creates a Choices type function that validates the input against allowed values.
|
|
7
13
|
* The display name will be formatted as "value1 | value2 | ..." for help output.
|
|
@@ -86,6 +92,28 @@ type FlagOptions = (BaseFlagOptions<BooleanConstructor> & {
|
|
|
86
92
|
});
|
|
87
93
|
type FlagDefinitionValue = FlagOptions | FlagType;
|
|
88
94
|
type FlagsDefinition = Record<string, FlagDefinitionValue>;
|
|
95
|
+
/**
|
|
96
|
+
* Configuration options for the parser.
|
|
97
|
+
*/
|
|
98
|
+
interface ParserOptions<T extends FlagsDefinition = {}> {
|
|
99
|
+
/**
|
|
100
|
+
* Detailed configuration for flags.
|
|
101
|
+
* Supports the full object syntax or a type constructor as a shorthand.
|
|
102
|
+
* The key is the flag name (e.g., "file" for "--file").
|
|
103
|
+
*/
|
|
104
|
+
flags?: T;
|
|
105
|
+
/**
|
|
106
|
+
* Delimiters to split flag names and values.
|
|
107
|
+
*
|
|
108
|
+
* @default ['=', ':']
|
|
109
|
+
*/
|
|
110
|
+
delimiters?: string[];
|
|
111
|
+
/**
|
|
112
|
+
* A callback function to conditionally stop parsing.
|
|
113
|
+
* When it returns true, parsing stops and remaining arguments are preserved in `ignored`.
|
|
114
|
+
*/
|
|
115
|
+
ignore?: IgnoreFunction;
|
|
116
|
+
}
|
|
89
117
|
type RawInputType = string | boolean;
|
|
90
118
|
interface ObjectInputType {
|
|
91
119
|
[key: string]: RawInputType | ObjectInputType;
|
|
@@ -141,6 +169,14 @@ declare const PARAMETER = "parameter";
|
|
|
141
169
|
//#endregion
|
|
142
170
|
//#region ../parser/src/parse.d.ts
|
|
143
171
|
declare const DOUBLE_DASH = "--";
|
|
172
|
+
type ParseFunction<T extends FlagsDefinition> = (args: string[]) => ParsedResult<InferFlags<T>>;
|
|
173
|
+
declare function createParser<T extends FlagsDefinition>(options?: ParserOptions<T>): {
|
|
174
|
+
parse: ParseFunction<T>;
|
|
175
|
+
};
|
|
176
|
+
declare const parse: <T extends FlagsDefinition>(args: string[], options?: ParserOptions<T>) => ParsedResult<InferFlags<T>>;
|
|
177
|
+
declare namespace index_d_exports {
|
|
178
|
+
export { BaseFlagOptions, Choices, DOUBLE_DASH, FlagDefaultValue, FlagDefinitionValue, FlagOptions, FlagType, FlagTypeFunction, FlagsDefinition, IgnoreFunction, InferFlags, InvalidSchemaError, KNOWN_FLAG, ObjectInputType, PARAMETER, ParsedResult, ParserOptions, RawInputType, UNKNOWN_FLAG, createParser, parse };
|
|
179
|
+
}
|
|
144
180
|
//#endregion
|
|
145
181
|
//#region src/types/clerc.d.ts
|
|
146
182
|
type ErrorHandler = (error: unknown) => void;
|
|
@@ -283,4 +319,4 @@ declare function createStopAtFirstParameter(): IgnoreFunction;
|
|
|
283
319
|
//#region src/plugin.d.ts
|
|
284
320
|
declare const definePlugin: (plugin: Plugin) => Plugin;
|
|
285
321
|
//#endregion
|
|
286
|
-
export { BaseContext, Choices, Clerc, ClercFlagOptions, ClercFlagOptionsWithDescription, ClercFlagsDefinition, ClercGlobalFlagDefinitionValue, Command, CommandCustomOptions, CommandHandler, CommandHandlerContext, CommandOptions, CommandWithHandler, CommandsMap, CommandsRecord, type CreateOptions, DOUBLE_DASH, ErrorHandler, FlagCustomOptions, InferParameters, Interceptor, InterceptorContext, InterceptorHandler, InterceptorNext, InterceptorObject, InvalidCommandError, InvalidParametersError, KNOWN_FLAG, MakeEmitterEvents, MissingRequiredMetadataError, NoCommandSpecifiedError, NoSuchCommandError, PARAMETER, type ParseOptions, Plugin, UNKNOWN_FLAG, createStopAtFirstParameter, defineCommand, definePlugin, resolveCommand };
|
|
322
|
+
export { BaseContext, Choices, Clerc, ClercFlagOptions, ClercFlagOptionsWithDescription, ClercFlagsDefinition, ClercGlobalFlagDefinitionValue, Command, CommandCustomOptions, CommandHandler, CommandHandlerContext, CommandOptions, CommandWithHandler, CommandsMap, CommandsRecord, type CreateOptions, DOUBLE_DASH, ErrorHandler, FlagCustomOptions, InferParameters, Interceptor, InterceptorContext, InterceptorHandler, InterceptorNext, InterceptorObject, InvalidCommandError, InvalidParametersError, InvalidSchemaError, KNOWN_FLAG, MakeEmitterEvents, MissingRequiredMetadataError, NoCommandSpecifiedError, NoSuchCommandError, PARAMETER, type ParseOptions, type index_d_exports as Parser, Plugin, UNKNOWN_FLAG, createStopAtFirstParameter, defineCommand, definePlugin, resolveCommand };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Choices, DOUBLE_DASH, DOUBLE_DASH as DOUBLE_DASH$1, KNOWN_FLAG, PARAMETER, PARAMETER as PARAMETER$1, UNKNOWN_FLAG, parse } from "@clerc/parser";
|
|
1
|
+
import { Choices, DOUBLE_DASH, DOUBLE_DASH as DOUBLE_DASH$1, InvalidSchemaError, KNOWN_FLAG, PARAMETER, PARAMETER as PARAMETER$1, UNKNOWN_FLAG, parse } from "@clerc/parser";
|
|
2
2
|
import { LiteEmit } from "lite-emit";
|
|
3
3
|
|
|
4
4
|
//#region ../utils/src/index.ts
|
|
@@ -348,4 +348,4 @@ function createStopAtFirstParameter() {
|
|
|
348
348
|
const definePlugin = (plugin) => plugin;
|
|
349
349
|
|
|
350
350
|
//#endregion
|
|
351
|
-
export { Choices, Clerc, DOUBLE_DASH, InvalidCommandError, InvalidParametersError, KNOWN_FLAG, MissingRequiredMetadataError, NoCommandSpecifiedError, NoSuchCommandError, PARAMETER, UNKNOWN_FLAG, createStopAtFirstParameter, defineCommand, definePlugin, resolveCommand };
|
|
351
|
+
export { Choices, Clerc, DOUBLE_DASH, InvalidCommandError, InvalidParametersError, InvalidSchemaError, KNOWN_FLAG, MissingRequiredMetadataError, NoCommandSpecifiedError, NoSuchCommandError, PARAMETER, UNKNOWN_FLAG, createStopAtFirstParameter, defineCommand, definePlugin, resolveCommand };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clerc/core",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.12",
|
|
4
4
|
"author": "Ray <i@mk1.io> (https://github.com/so1ve)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Clerc core",
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"lite-emit": "^3.1.0",
|
|
48
|
-
"@clerc/parser": "^1.0.0-beta.
|
|
48
|
+
"@clerc/parser": "^1.0.0-beta.12"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"is-platform": "^1.0.0",
|
|
52
|
-
"@clerc/utils": "1.0.0-beta.
|
|
52
|
+
"@clerc/utils": "1.0.0-beta.12"
|
|
53
53
|
}
|
|
54
54
|
}
|