@clerc/core 0.21.0 → 0.22.0
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 +20 -20
- package/dist/index.js +25 -25
- package/dist/index.mjs +25 -25
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -69,7 +69,7 @@ type TypeFlag<Schemas extends Flags> = ParsedFlags<{
|
|
|
69
69
|
[flag in keyof Schemas]: InferFlagType<Schemas[flag]>;
|
|
70
70
|
}>;
|
|
71
71
|
|
|
72
|
-
type CommandType =
|
|
72
|
+
type CommandType = RootType | string;
|
|
73
73
|
type FlagOptions = FlagSchema & {
|
|
74
74
|
description?: string;
|
|
75
75
|
};
|
|
@@ -78,27 +78,27 @@ type Flag = FlagOptions & {
|
|
|
78
78
|
};
|
|
79
79
|
declare interface CommandCustomProperties {
|
|
80
80
|
}
|
|
81
|
-
interface CommandOptions<P extends string[] = string[], A extends MaybeArray<string |
|
|
81
|
+
interface CommandOptions<P extends string[] = string[], A extends MaybeArray<string | RootType> = MaybeArray<string | RootType>, F extends Dict<FlagOptions> = Dict<FlagOptions>> extends CommandCustomProperties {
|
|
82
82
|
alias?: A;
|
|
83
83
|
parameters?: P;
|
|
84
84
|
flags?: F;
|
|
85
85
|
examples?: [string, string][];
|
|
86
86
|
notes?: string[];
|
|
87
87
|
}
|
|
88
|
-
type Command<N extends string |
|
|
88
|
+
type Command<N extends string | RootType = string, O extends CommandOptions = CommandOptions> = O & {
|
|
89
89
|
name: N;
|
|
90
90
|
description: string;
|
|
91
91
|
};
|
|
92
|
-
type CommandAlias<N extends string |
|
|
92
|
+
type CommandAlias<N extends string | RootType = string, O extends CommandOptions = CommandOptions> = Command<N, O> & {
|
|
93
93
|
__isAlias?: true;
|
|
94
94
|
};
|
|
95
|
-
type CommandWithHandler<N extends string |
|
|
95
|
+
type CommandWithHandler<N extends string | RootType = string, O extends CommandOptions = CommandOptions> = Command<N, O> & {
|
|
96
96
|
handler?: HandlerInCommand<Record<N, Command<N, O>> & Record<never, never>, N>;
|
|
97
97
|
};
|
|
98
98
|
type StripBrackets<Parameter extends string> = (Parameter extends `<${infer ParameterName}>` | `[${infer ParameterName}]` ? (ParameterName extends `${infer SpreadName}...` ? SpreadName : ParameterName) : never);
|
|
99
99
|
type ParameterType<Parameter extends string> = (Parameter extends `<${infer _ParameterName}...>` | `[${infer _ParameterName}...]` ? string[] : Parameter extends `<${infer _ParameterName}>` ? string : Parameter extends `[${infer _ParameterName}]` ? string | undefined : never);
|
|
100
100
|
type CommandRecord = Dict<Command> & {
|
|
101
|
-
[
|
|
101
|
+
[Root]?: Command;
|
|
102
102
|
};
|
|
103
103
|
type MakeEventMap<T extends CommandRecord> = {
|
|
104
104
|
[K in keyof T]: [InspectorContext];
|
|
@@ -120,10 +120,10 @@ type Raw<C extends CommandRecord = CommandRecord, N extends keyof C = keyof C> =
|
|
|
120
120
|
};
|
|
121
121
|
interface HandlerContext<C extends CommandRecord = CommandRecord, N extends keyof C = keyof C> {
|
|
122
122
|
name: N extends keyof C ? N : N | undefined;
|
|
123
|
-
called?: string |
|
|
123
|
+
called?: string | RootType;
|
|
124
124
|
resolved: N extends keyof C ? true : boolean;
|
|
125
|
-
|
|
126
|
-
|
|
125
|
+
hasRootOrAlias: boolean;
|
|
126
|
+
hasRoot: boolean;
|
|
127
127
|
raw: Raw<C, N>;
|
|
128
128
|
parameters: TransformParameters<C, N>;
|
|
129
129
|
unknownFlags: ParsedFlags["unknownFlags"];
|
|
@@ -148,8 +148,8 @@ interface Plugin<T extends Clerc = Clerc, U extends Clerc = Clerc> {
|
|
|
148
148
|
setup: (cli: T) => U;
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
-
declare const
|
|
152
|
-
type
|
|
151
|
+
declare const Root: unique symbol;
|
|
152
|
+
type RootType = typeof Root;
|
|
153
153
|
declare class Clerc<C extends CommandRecord = {}> {
|
|
154
154
|
#private;
|
|
155
155
|
private constructor();
|
|
@@ -220,7 +220,7 @@ declare class Clerc<C extends CommandRecord = {}> {
|
|
|
220
220
|
* @example
|
|
221
221
|
* ```ts
|
|
222
222
|
* Clerc.create()
|
|
223
|
-
* .command("", "
|
|
223
|
+
* .command("", "root", {
|
|
224
224
|
* flags: {
|
|
225
225
|
* foo: {
|
|
226
226
|
* alias: "f",
|
|
@@ -230,8 +230,8 @@ declare class Clerc<C extends CommandRecord = {}> {
|
|
|
230
230
|
* })
|
|
231
231
|
* ```
|
|
232
232
|
*/
|
|
233
|
-
command<N extends string |
|
|
234
|
-
command<N extends string |
|
|
233
|
+
command<N extends string | RootType, O extends CommandOptions<[...P], A, F>, P extends string[] = string[], A extends MaybeArray<string | RootType> = MaybeArray<string | RootType>, F extends Dict<FlagOptions> = Dict<FlagOptions>>(c: CommandWithHandler<N, O & CommandOptions<[...P], A, F>>): this & Clerc<C & Record<N, Command<N, O>>>;
|
|
234
|
+
command<N extends string | RootType, O extends CommandOptions<[...P], A, F>, P extends string[] = string[], A extends MaybeArray<string | RootType> = MaybeArray<string | RootType>, F extends Dict<FlagOptions> = Dict<FlagOptions>>(name: N, description: string, options?: O & CommandOptions<[...P], A, F>): this & Clerc<C & Record<N, Command<N, O>>>;
|
|
235
235
|
/**
|
|
236
236
|
* Register a handler
|
|
237
237
|
* @param name
|
|
@@ -288,7 +288,7 @@ declare class Clerc<C extends CommandRecord = {}> {
|
|
|
288
288
|
declare const definePlugin: <T extends Clerc<{}>, U extends Clerc<{}>>(p: Plugin<T, U>) => Plugin<T, U>;
|
|
289
289
|
declare const defineHandler: <C extends Clerc<{}>, K extends keyof C["_commands"]>(_cli: C, _key: K, handler: Handler<C["_commands"], K>) => Handler<C["_commands"], K>;
|
|
290
290
|
declare const defineInspector: <C extends Clerc<{}>>(_cli: C, inspector: Inspector<C["_commands"]>) => Inspector<C["_commands"]>;
|
|
291
|
-
declare const defineCommand: <N extends string | typeof
|
|
291
|
+
declare const defineCommand: <N extends string | typeof Root, O extends CommandOptions<[...P], A, F>, P extends string[] = string[], A extends MaybeArray<string> = MaybeArray<string>, F extends Dict<FlagOptions> = Dict<FlagOptions>>(command: CommandWithHandler<N, O & CommandOptions<[...P], A, F>>) => CommandWithHandler<N, O & CommandOptions<[...P], A, F>>;
|
|
292
292
|
|
|
293
293
|
declare class CommandExistsError extends Error {
|
|
294
294
|
name: string;
|
|
@@ -320,10 +320,10 @@ declare class InvalidCommandNameError extends Error {
|
|
|
320
320
|
constructor(name: string);
|
|
321
321
|
}
|
|
322
322
|
|
|
323
|
-
declare function resolveFlattenCommands(commands: CommandRecord): Map<string[] | typeof
|
|
324
|
-
declare function resolveCommand(commands: CommandRecord, name: string | string[] |
|
|
325
|
-
declare function resolveSubcommandsByParent(commands: CommandRecord, parent: string | string[], depth?: number): Command<string, CommandOptions<string[], _clerc_utils.MaybeArray<string | typeof
|
|
326
|
-
declare const resolveRootCommands: (commands: CommandRecord) => Command<string, CommandOptions<string[], _clerc_utils.MaybeArray<string | typeof
|
|
323
|
+
declare function resolveFlattenCommands(commands: CommandRecord): Map<string[] | typeof Root, CommandAlias<string, CommandOptions<string[], _clerc_utils.MaybeArray<string | typeof Root>, _clerc_utils.Dict<FlagOptions>>>>;
|
|
324
|
+
declare function resolveCommand(commands: CommandRecord, name: string | string[] | RootType): Command<string | RootType> | undefined;
|
|
325
|
+
declare function resolveSubcommandsByParent(commands: CommandRecord, parent: string | string[], depth?: number): Command<string, CommandOptions<string[], _clerc_utils.MaybeArray<string | typeof Root>, _clerc_utils.Dict<FlagOptions>>>[];
|
|
326
|
+
declare const resolveRootCommands: (commands: CommandRecord) => Command<string, CommandOptions<string[], _clerc_utils.MaybeArray<string | typeof Root>, _clerc_utils.Dict<FlagOptions>>>[];
|
|
327
327
|
declare function resolveParametersBeforeFlag(argv: string[]): string[];
|
|
328
328
|
declare const resolveArgv: () => string[];
|
|
329
329
|
declare function compose(inspectors: Inspector[]): (getCtx: () => InspectorContext) => void;
|
|
@@ -337,4 +337,4 @@ interface ParsedParameter {
|
|
|
337
337
|
declare function parseParameters(parameters: string[]): ParsedParameter[];
|
|
338
338
|
declare function mapParametersToArguments(mapping: Record<string, string | string[]>, parameters: ParsedParameter[], cliArguments: string[]): Error | undefined;
|
|
339
339
|
|
|
340
|
-
export { Clerc, Command, CommandAlias, CommandCustomProperties, CommandExistsError, CommandNameConflictError, CommandOptions, CommandRecord, CommandType, CommandWithHandler, DescriptionNotSetError, FallbackType, Flag, FlagOptions, Handler, HandlerContext, HandlerInCommand, Inspector, InspectorContext, InspectorFn, InspectorObject, InvalidCommandNameError, MakeEventMap, NameNotSetError, NoCommandGivenError, NoSuchCommandError, Plugin, PossibleInputKind,
|
|
340
|
+
export { Clerc, Command, CommandAlias, CommandCustomProperties, CommandExistsError, CommandNameConflictError, CommandOptions, CommandRecord, CommandType, CommandWithHandler, DescriptionNotSetError, FallbackType, Flag, FlagOptions, Handler, HandlerContext, HandlerInCommand, Inspector, InspectorContext, InspectorFn, InspectorObject, InvalidCommandNameError, MakeEventMap, NameNotSetError, NoCommandGivenError, NoSuchCommandError, Plugin, PossibleInputKind, Root, RootType, VersionNotSetError, compose, defineCommand, defineHandler, defineInspector, definePlugin, isInvalidName, mapParametersToArguments, parseParameters, resolveArgv, resolveCommand, resolveFlattenCommands, resolveParametersBeforeFlag, resolveRootCommands, resolveSubcommandsByParent };
|
package/dist/index.js
CHANGED
|
@@ -62,9 +62,9 @@ function setCommand(commandsMap, commands, command) {
|
|
|
62
62
|
}
|
|
63
63
|
function resolveFlattenCommands(commands) {
|
|
64
64
|
const commandsMap = /* @__PURE__ */ new Map();
|
|
65
|
-
if (commands[
|
|
66
|
-
commandsMap.set(
|
|
67
|
-
setCommand(commandsMap, commands, commands[
|
|
65
|
+
if (commands[Root]) {
|
|
66
|
+
commandsMap.set(Root, commands[Root]);
|
|
67
|
+
setCommand(commandsMap, commands, commands[Root]);
|
|
68
68
|
}
|
|
69
69
|
for (const command of Object.values(commands)) {
|
|
70
70
|
setCommand(commandsMap, commands, command);
|
|
@@ -73,20 +73,20 @@ function resolveFlattenCommands(commands) {
|
|
|
73
73
|
return commandsMap;
|
|
74
74
|
}
|
|
75
75
|
function resolveCommand(commands, name) {
|
|
76
|
-
if (name ===
|
|
77
|
-
return commands[
|
|
76
|
+
if (name === Root) {
|
|
77
|
+
return commands[Root];
|
|
78
78
|
}
|
|
79
79
|
const nameArr = toArray(name);
|
|
80
80
|
const commandsMap = resolveFlattenCommands(commands);
|
|
81
81
|
let current;
|
|
82
82
|
let currentName;
|
|
83
83
|
commandsMap.forEach((v, k) => {
|
|
84
|
-
if (k ===
|
|
85
|
-
current = commandsMap.get(
|
|
86
|
-
currentName =
|
|
84
|
+
if (k === Root) {
|
|
85
|
+
current = commandsMap.get(Root);
|
|
86
|
+
currentName = Root;
|
|
87
87
|
return;
|
|
88
88
|
}
|
|
89
|
-
if (arrayStartsWith(nameArr, k) && (!currentName || currentName ===
|
|
89
|
+
if (arrayStartsWith(nameArr, k) && (!currentName || currentName === Root || k.length > currentName.length)) {
|
|
90
90
|
current = v;
|
|
91
91
|
currentName = k;
|
|
92
92
|
}
|
|
@@ -211,12 +211,12 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
211
211
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
212
212
|
return value;
|
|
213
213
|
};
|
|
214
|
-
var _name, _description, _version, _inspectors, _commands, _commandEmitter, _usedNames,
|
|
215
|
-
const
|
|
214
|
+
var _name, _description, _version, _inspectors, _commands, _commandEmitter, _usedNames, _hasRootOrAlias, hasRootOrAlias_get, _hasRoot, hasRoot_get;
|
|
215
|
+
const Root = Symbol("Root");
|
|
216
216
|
const _Clerc = class {
|
|
217
217
|
constructor(name, description, version) {
|
|
218
|
-
__privateAdd(this,
|
|
219
|
-
__privateAdd(this,
|
|
218
|
+
__privateAdd(this, _hasRootOrAlias);
|
|
219
|
+
__privateAdd(this, _hasRoot);
|
|
220
220
|
__privateAdd(this, _name, "");
|
|
221
221
|
__privateAdd(this, _description, "");
|
|
222
222
|
__privateAdd(this, _version, "");
|
|
@@ -259,7 +259,7 @@ const _Clerc = class {
|
|
|
259
259
|
return this;
|
|
260
260
|
}
|
|
261
261
|
command(nameOrCommand, description, options = {}) {
|
|
262
|
-
const checkIsCommandObject = (nameOrCommand2) => !(typeof nameOrCommand2 === "string" || nameOrCommand2 ===
|
|
262
|
+
const checkIsCommandObject = (nameOrCommand2) => !(typeof nameOrCommand2 === "string" || nameOrCommand2 === Root);
|
|
263
263
|
const isCommandObject = checkIsCommandObject(nameOrCommand);
|
|
264
264
|
const name = !isCommandObject ? nameOrCommand : nameOrCommand.name;
|
|
265
265
|
if (__privateGet(this, _commands)[name]) {
|
|
@@ -312,7 +312,7 @@ const _Clerc = class {
|
|
|
312
312
|
const isCommandResolved = !!command;
|
|
313
313
|
const parsed = typeFlag((command == null ? void 0 : command.flags) || {}, [...argv]);
|
|
314
314
|
const { _: args, flags, unknownFlags } = parsed;
|
|
315
|
-
let parameters = !isCommandResolved || command.name ===
|
|
315
|
+
let parameters = !isCommandResolved || command.name === Root ? args : args.slice(command.name.split(" ").length);
|
|
316
316
|
let commandParameters = (command == null ? void 0 : command.parameters) || [];
|
|
317
317
|
const hasEof = commandParameters.indexOf("--");
|
|
318
318
|
const eofParameters = commandParameters.slice(hasEof + 1) || [];
|
|
@@ -341,10 +341,10 @@ const _Clerc = class {
|
|
|
341
341
|
const mergedFlags = { ...flags, ...unknownFlags };
|
|
342
342
|
const context = {
|
|
343
343
|
name: command == null ? void 0 : command.name,
|
|
344
|
-
called: name.length === 0 ?
|
|
344
|
+
called: name.length === 0 ? Root : stringName,
|
|
345
345
|
resolved: isCommandResolved,
|
|
346
|
-
|
|
347
|
-
|
|
346
|
+
hasRootOrAlias: __privateGet(this, _hasRootOrAlias, hasRootOrAlias_get),
|
|
347
|
+
hasRoot: __privateGet(this, _hasRoot, hasRoot_get),
|
|
348
348
|
raw: { ...parsed, parameters, mergedFlags },
|
|
349
349
|
parameters: mapping,
|
|
350
350
|
flags,
|
|
@@ -386,13 +386,13 @@ _inspectors = new WeakMap();
|
|
|
386
386
|
_commands = new WeakMap();
|
|
387
387
|
_commandEmitter = new WeakMap();
|
|
388
388
|
_usedNames = new WeakMap();
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
return __privateGet(this, _usedNames).includes(
|
|
389
|
+
_hasRootOrAlias = new WeakSet();
|
|
390
|
+
hasRootOrAlias_get = function() {
|
|
391
|
+
return __privateGet(this, _usedNames).includes(Root);
|
|
392
392
|
};
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
return !!__privateGet(this, _commands)[
|
|
393
|
+
_hasRoot = new WeakSet();
|
|
394
|
+
hasRoot_get = function() {
|
|
395
|
+
return !!__privateGet(this, _commands)[Root];
|
|
396
396
|
};
|
|
397
397
|
|
|
398
398
|
const definePlugin = (p) => p;
|
|
@@ -400,4 +400,4 @@ const defineHandler = (_cli, _key, handler) => handler;
|
|
|
400
400
|
const defineInspector = (_cli, inspector) => inspector;
|
|
401
401
|
const defineCommand = (command) => command;
|
|
402
402
|
|
|
403
|
-
export { Clerc, CommandExistsError, CommandNameConflictError, DescriptionNotSetError, InvalidCommandNameError, NameNotSetError, NoCommandGivenError, NoSuchCommandError,
|
|
403
|
+
export { Clerc, CommandExistsError, CommandNameConflictError, DescriptionNotSetError, InvalidCommandNameError, NameNotSetError, NoCommandGivenError, NoSuchCommandError, Root, VersionNotSetError, compose, defineCommand, defineHandler, defineInspector, definePlugin, isInvalidName, mapParametersToArguments, parseParameters, resolveArgv, resolveCommand, resolveFlattenCommands, resolveParametersBeforeFlag, resolveRootCommands, resolveSubcommandsByParent };
|
package/dist/index.mjs
CHANGED
|
@@ -62,9 +62,9 @@ function setCommand(commandsMap, commands, command) {
|
|
|
62
62
|
}
|
|
63
63
|
function resolveFlattenCommands(commands) {
|
|
64
64
|
const commandsMap = /* @__PURE__ */ new Map();
|
|
65
|
-
if (commands[
|
|
66
|
-
commandsMap.set(
|
|
67
|
-
setCommand(commandsMap, commands, commands[
|
|
65
|
+
if (commands[Root]) {
|
|
66
|
+
commandsMap.set(Root, commands[Root]);
|
|
67
|
+
setCommand(commandsMap, commands, commands[Root]);
|
|
68
68
|
}
|
|
69
69
|
for (const command of Object.values(commands)) {
|
|
70
70
|
setCommand(commandsMap, commands, command);
|
|
@@ -73,20 +73,20 @@ function resolveFlattenCommands(commands) {
|
|
|
73
73
|
return commandsMap;
|
|
74
74
|
}
|
|
75
75
|
function resolveCommand(commands, name) {
|
|
76
|
-
if (name ===
|
|
77
|
-
return commands[
|
|
76
|
+
if (name === Root) {
|
|
77
|
+
return commands[Root];
|
|
78
78
|
}
|
|
79
79
|
const nameArr = toArray(name);
|
|
80
80
|
const commandsMap = resolveFlattenCommands(commands);
|
|
81
81
|
let current;
|
|
82
82
|
let currentName;
|
|
83
83
|
commandsMap.forEach((v, k) => {
|
|
84
|
-
if (k ===
|
|
85
|
-
current = commandsMap.get(
|
|
86
|
-
currentName =
|
|
84
|
+
if (k === Root) {
|
|
85
|
+
current = commandsMap.get(Root);
|
|
86
|
+
currentName = Root;
|
|
87
87
|
return;
|
|
88
88
|
}
|
|
89
|
-
if (arrayStartsWith(nameArr, k) && (!currentName || currentName ===
|
|
89
|
+
if (arrayStartsWith(nameArr, k) && (!currentName || currentName === Root || k.length > currentName.length)) {
|
|
90
90
|
current = v;
|
|
91
91
|
currentName = k;
|
|
92
92
|
}
|
|
@@ -211,12 +211,12 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
211
211
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
212
212
|
return value;
|
|
213
213
|
};
|
|
214
|
-
var _name, _description, _version, _inspectors, _commands, _commandEmitter, _usedNames,
|
|
215
|
-
const
|
|
214
|
+
var _name, _description, _version, _inspectors, _commands, _commandEmitter, _usedNames, _hasRootOrAlias, hasRootOrAlias_get, _hasRoot, hasRoot_get;
|
|
215
|
+
const Root = Symbol("Root");
|
|
216
216
|
const _Clerc = class {
|
|
217
217
|
constructor(name, description, version) {
|
|
218
|
-
__privateAdd(this,
|
|
219
|
-
__privateAdd(this,
|
|
218
|
+
__privateAdd(this, _hasRootOrAlias);
|
|
219
|
+
__privateAdd(this, _hasRoot);
|
|
220
220
|
__privateAdd(this, _name, "");
|
|
221
221
|
__privateAdd(this, _description, "");
|
|
222
222
|
__privateAdd(this, _version, "");
|
|
@@ -259,7 +259,7 @@ const _Clerc = class {
|
|
|
259
259
|
return this;
|
|
260
260
|
}
|
|
261
261
|
command(nameOrCommand, description, options = {}) {
|
|
262
|
-
const checkIsCommandObject = (nameOrCommand2) => !(typeof nameOrCommand2 === "string" || nameOrCommand2 ===
|
|
262
|
+
const checkIsCommandObject = (nameOrCommand2) => !(typeof nameOrCommand2 === "string" || nameOrCommand2 === Root);
|
|
263
263
|
const isCommandObject = checkIsCommandObject(nameOrCommand);
|
|
264
264
|
const name = !isCommandObject ? nameOrCommand : nameOrCommand.name;
|
|
265
265
|
if (__privateGet(this, _commands)[name]) {
|
|
@@ -312,7 +312,7 @@ const _Clerc = class {
|
|
|
312
312
|
const isCommandResolved = !!command;
|
|
313
313
|
const parsed = typeFlag((command == null ? void 0 : command.flags) || {}, [...argv]);
|
|
314
314
|
const { _: args, flags, unknownFlags } = parsed;
|
|
315
|
-
let parameters = !isCommandResolved || command.name ===
|
|
315
|
+
let parameters = !isCommandResolved || command.name === Root ? args : args.slice(command.name.split(" ").length);
|
|
316
316
|
let commandParameters = (command == null ? void 0 : command.parameters) || [];
|
|
317
317
|
const hasEof = commandParameters.indexOf("--");
|
|
318
318
|
const eofParameters = commandParameters.slice(hasEof + 1) || [];
|
|
@@ -341,10 +341,10 @@ const _Clerc = class {
|
|
|
341
341
|
const mergedFlags = { ...flags, ...unknownFlags };
|
|
342
342
|
const context = {
|
|
343
343
|
name: command == null ? void 0 : command.name,
|
|
344
|
-
called: name.length === 0 ?
|
|
344
|
+
called: name.length === 0 ? Root : stringName,
|
|
345
345
|
resolved: isCommandResolved,
|
|
346
|
-
|
|
347
|
-
|
|
346
|
+
hasRootOrAlias: __privateGet(this, _hasRootOrAlias, hasRootOrAlias_get),
|
|
347
|
+
hasRoot: __privateGet(this, _hasRoot, hasRoot_get),
|
|
348
348
|
raw: { ...parsed, parameters, mergedFlags },
|
|
349
349
|
parameters: mapping,
|
|
350
350
|
flags,
|
|
@@ -386,13 +386,13 @@ _inspectors = new WeakMap();
|
|
|
386
386
|
_commands = new WeakMap();
|
|
387
387
|
_commandEmitter = new WeakMap();
|
|
388
388
|
_usedNames = new WeakMap();
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
return __privateGet(this, _usedNames).includes(
|
|
389
|
+
_hasRootOrAlias = new WeakSet();
|
|
390
|
+
hasRootOrAlias_get = function() {
|
|
391
|
+
return __privateGet(this, _usedNames).includes(Root);
|
|
392
392
|
};
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
return !!__privateGet(this, _commands)[
|
|
393
|
+
_hasRoot = new WeakSet();
|
|
394
|
+
hasRoot_get = function() {
|
|
395
|
+
return !!__privateGet(this, _commands)[Root];
|
|
396
396
|
};
|
|
397
397
|
|
|
398
398
|
const definePlugin = (p) => p;
|
|
@@ -400,4 +400,4 @@ const defineHandler = (_cli, _key, handler) => handler;
|
|
|
400
400
|
const defineInspector = (_cli, inspector) => inspector;
|
|
401
401
|
const defineCommand = (command) => command;
|
|
402
402
|
|
|
403
|
-
export { Clerc, CommandExistsError, CommandNameConflictError, DescriptionNotSetError, InvalidCommandNameError, NameNotSetError, NoCommandGivenError, NoSuchCommandError,
|
|
403
|
+
export { Clerc, CommandExistsError, CommandNameConflictError, DescriptionNotSetError, InvalidCommandNameError, NameNotSetError, NoCommandGivenError, NoSuchCommandError, Root, VersionNotSetError, compose, defineCommand, defineHandler, defineInspector, definePlugin, isInvalidName, mapParametersToArguments, parseParameters, resolveArgv, resolveCommand, resolveFlattenCommands, resolveParametersBeforeFlag, resolveRootCommands, resolveSubcommandsByParent };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clerc/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"author": "Ray <nn_201312@163.com> (https://github.com/so1ve)",
|
|
5
5
|
"description": "Clerc core",
|
|
6
6
|
"keywords": [
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"is-platform": "^0.2.0",
|
|
51
51
|
"lite-emit": "^1.4.0",
|
|
52
52
|
"type-flag": "^3.0.0",
|
|
53
|
-
"@clerc/utils": "0.
|
|
53
|
+
"@clerc/utils": "0.22.0"
|
|
54
54
|
},
|
|
55
55
|
"scripts": {
|
|
56
56
|
"build": "puild",
|