@duplojs/server 0.1.0-beta.1 → 0.1.0-beta.10
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/_virtual/_rolldown/runtime.mjs +5 -1
- package/dist/command/argument.d.ts +2 -2
- package/dist/command/create.cjs +18 -10
- package/dist/command/create.d.ts +3 -3
- package/dist/command/create.mjs +18 -10
- package/dist/command/error.cjs +96 -43
- package/dist/command/error.d.ts +9 -1
- package/dist/command/error.mjs +95 -42
- package/dist/command/exec.d.ts +4 -3
- package/dist/command/help.cjs +28 -35
- package/dist/command/help.d.ts +1 -1
- package/dist/command/help.mjs +27 -34
- package/dist/command/index.cjs +4 -0
- package/dist/command/index.mjs +4 -2
- package/dist/command/options/base.cjs +21 -13
- package/dist/command/options/base.d.ts +6 -0
- package/dist/command/options/base.mjs +20 -14
- package/dist/command/options/defaults/array.d.ts +6 -4
- package/dist/command/options/defaults/boolean.cjs +21 -7
- package/dist/command/options/defaults/boolean.d.ts +6 -3
- package/dist/command/options/defaults/boolean.mjs +20 -8
- package/dist/command/options/defaults/simple.d.ts +6 -4
- package/dist/command/types/forbiddenInvalidIdentifier.d.ts +6 -0
- package/dist/command/types/index.d.ts +1 -0
- package/dist/common/environmentVariable/index.d.ts +1 -1
- package/dist/common/environmentVariable/overrideEnvironmentVariables.d.ts +1 -1
- package/dist/common/environmentVariable/parseEnvironmentFiles.d.ts +2 -1
- package/dist/common/index.cjs +3 -0
- package/dist/common/index.d.ts +1 -0
- package/dist/common/index.mjs +3 -1
- package/dist/common/meta/getCurrentDirectoryName.cjs +10 -0
- package/dist/common/meta/getCurrentDirectoryName.d.ts +7 -0
- package/dist/common/meta/getCurrentDirectoryName.mjs +7 -0
- package/dist/common/meta/index.d.ts +7 -0
- package/dist/dataStructure/common/codec/defaults/json.cjs +12 -1
- package/dist/dataStructure/common/codec/defaults/json.d.ts +2 -2
- package/dist/dataStructure/common/codec/defaults/json.mjs +12 -1
- package/dist/dataStructure/common/codec/defaults/string.cjs +12 -1
- package/dist/dataStructure/common/codec/defaults/string.d.ts +2 -2
- package/dist/dataStructure/common/codec/defaults/string.mjs +12 -1
- package/dist/dataStructure/common/error/defaultInterpreter.cjs +3 -1
- package/dist/dataStructure/common/error/defaultInterpreter.d.ts +7 -2
- package/dist/dataStructure/common/error/defaultInterpreter.mjs +3 -1
- package/dist/dataStructure/constraint/{exist.cjs → fileExist.cjs} +5 -5
- package/dist/dataStructure/constraint/fileExist.d.ts +10 -0
- package/dist/dataStructure/constraint/{exist.mjs → fileExist.mjs} +4 -4
- package/dist/dataStructure/constraint/folderExist.cjs +19 -0
- package/dist/dataStructure/constraint/folderExist.d.ts +10 -0
- package/dist/dataStructure/constraint/folderExist.mjs +15 -0
- package/dist/dataStructure/constraint/index.d.ts +2 -1
- package/dist/dataStructure/constraint/mimeType.cjs +1 -1
- package/dist/dataStructure/constraint/mimeType.mjs +1 -1
- package/dist/dataStructure/constraint/types/constraints.d.ts +4 -2
- package/dist/dataStructure/fundamentalType/folder.cjs +11 -0
- package/dist/dataStructure/fundamentalType/folder.d.ts +8 -0
- package/dist/dataStructure/fundamentalType/folder.mjs +8 -0
- package/dist/dataStructure/fundamentalType/index.d.ts +1 -0
- package/dist/dataStructure/fundamentalType/types/fundamentalTypes.d.ts +2 -0
- package/dist/dataStructure/helper/file.d.ts +1 -1
- package/dist/dataStructure/helper/fileExist.cjs +7 -0
- package/dist/dataStructure/helper/fileExist.d.ts +2 -0
- package/dist/dataStructure/helper/fileExist.mjs +7 -0
- package/dist/dataStructure/helper/folder.cjs +10 -0
- package/dist/dataStructure/helper/folder.d.ts +3 -0
- package/dist/dataStructure/helper/folder.mjs +8 -0
- package/dist/dataStructure/helper/folderExist.cjs +7 -0
- package/dist/dataStructure/helper/folderExist.d.ts +2 -0
- package/dist/dataStructure/helper/folderExist.mjs +7 -0
- package/dist/dataStructure/helper/index.d.ts +3 -1
- package/dist/dataStructure/index.cjs +29 -8
- package/dist/dataStructure/index.mjs +19 -6
- package/dist/dataStructure/type/folder.cjs +14 -0
- package/dist/dataStructure/type/folder.d.ts +11 -0
- package/dist/dataStructure/type/folder.mjs +11 -0
- package/dist/dataStructure/type/index.d.ts +1 -0
- package/dist/dataStructure/type/types/types.d.ts +2 -0
- package/dist/file/appendFile.cjs +46 -22
- package/dist/file/appendFile.d.ts +37 -5
- package/dist/file/appendFile.mjs +36 -23
- package/dist/file/appendTextFile.cjs +44 -20
- package/dist/file/appendTextFile.d.ts +37 -5
- package/dist/file/appendTextFile.mjs +34 -21
- package/dist/file/copy.cjs +36 -14
- package/dist/file/copy.d.ts +37 -5
- package/dist/file/copy.mjs +26 -15
- package/dist/file/createEntryInterface.cjs +6 -3
- package/dist/file/createEntryInterface.d.ts +1 -1
- package/dist/file/createEntryInterface.mjs +4 -2
- package/dist/file/ensureDirectory.cjs +37 -17
- package/dist/file/ensureDirectory.d.ts +30 -4
- package/dist/file/ensureDirectory.mjs +29 -18
- package/dist/file/ensureFile.cjs +41 -19
- package/dist/file/ensureFile.d.ts +33 -4
- package/dist/file/ensureFile.mjs +32 -20
- package/dist/file/exists.cjs +28 -14
- package/dist/file/exists.d.ts +21 -4
- package/dist/file/exists.mjs +23 -15
- package/dist/file/fileInterface.cjs +3 -1
- package/dist/file/fileInterface.d.ts +10 -9
- package/dist/file/fileInterface.mjs +3 -2
- package/dist/file/folderInterface.cjs +3 -1
- package/dist/file/folderInterface.d.ts +9 -8
- package/dist/file/folderInterface.mjs +3 -2
- package/dist/file/index.cjs +512 -0
- package/dist/file/index.d.ts +0 -1
- package/dist/file/index.mjs +291 -35
- package/dist/file/link.cjs +48 -22
- package/dist/file/link.d.ts +40 -5
- package/dist/file/link.mjs +37 -23
- package/dist/file/linkStat.cjs +29 -15
- package/dist/file/linkStat.d.ts +24 -4
- package/dist/file/linkStat.mjs +24 -16
- package/dist/file/makeDirectory.cjs +45 -21
- package/dist/file/makeDirectory.d.ts +35 -4
- package/dist/file/makeDirectory.mjs +35 -22
- package/dist/file/makeTemporaryDirectory.cjs +33 -15
- package/dist/file/makeTemporaryDirectory.d.ts +25 -2
- package/dist/file/makeTemporaryDirectory.mjs +26 -16
- package/dist/file/makeTemporaryFile.cjs +37 -20
- package/dist/file/makeTemporaryFile.d.ts +28 -2
- package/dist/file/makeTemporaryFile.mjs +30 -21
- package/dist/file/move.cjs +49 -23
- package/dist/file/move.d.ts +40 -5
- package/dist/file/move.mjs +38 -24
- package/dist/file/readDirectory.cjs +33 -9
- package/dist/file/readDirectory.d.ts +26 -5
- package/dist/file/readDirectory.mjs +25 -10
- package/dist/file/readFile.cjs +35 -17
- package/dist/file/readFile.d.ts +27 -4
- package/dist/file/readFile.mjs +28 -18
- package/dist/file/readJsonFile.cjs +35 -17
- package/dist/file/readJsonFile.d.ts +27 -5
- package/dist/file/readJsonFile.mjs +28 -18
- package/dist/file/readLink.cjs +31 -15
- package/dist/file/readLink.d.ts +24 -4
- package/dist/file/readLink.mjs +25 -16
- package/dist/file/readTextFile.cjs +35 -17
- package/dist/file/readTextFile.d.ts +27 -4
- package/dist/file/readTextFile.mjs +28 -18
- package/dist/file/realPath.cjs +27 -13
- package/dist/file/realPath.d.ts +21 -4
- package/dist/file/realPath.mjs +22 -14
- package/dist/file/relocate.cjs +52 -25
- package/dist/file/relocate.d.ts +40 -5
- package/dist/file/relocate.mjs +41 -26
- package/dist/file/remove.cjs +45 -23
- package/dist/file/remove.d.ts +32 -4
- package/dist/file/remove.mjs +36 -24
- package/dist/file/rename.cjs +52 -25
- package/dist/file/rename.d.ts +40 -5
- package/dist/file/rename.mjs +41 -26
- package/dist/file/setMode.cjs +29 -15
- package/dist/file/setMode.d.ts +24 -5
- package/dist/file/setMode.mjs +24 -16
- package/dist/file/setOwner.cjs +31 -15
- package/dist/file/setOwner.d.ts +25 -5
- package/dist/file/setOwner.mjs +25 -16
- package/dist/file/setTime.cjs +31 -15
- package/dist/file/setTime.d.ts +24 -5
- package/dist/file/setTime.mjs +25 -16
- package/dist/file/stat.cjs +29 -15
- package/dist/file/stat.d.ts +24 -4
- package/dist/file/stat.mjs +24 -16
- package/dist/file/symlink.cjs +42 -20
- package/dist/file/symlink.d.ts +34 -5
- package/dist/file/symlink.mjs +33 -21
- package/dist/file/truncate.cjs +43 -21
- package/dist/file/truncate.d.ts +36 -4
- package/dist/file/truncate.mjs +34 -22
- package/dist/file/unknownEntryInterface.cjs +5 -1
- package/dist/file/unknownEntryInterface.d.ts +8 -6
- package/dist/file/unknownEntryInterface.mjs +4 -2
- package/dist/file/walkDirectory.cjs +38 -15
- package/dist/file/walkDirectory.d.ts +25 -4
- package/dist/file/walkDirectory.mjs +32 -15
- package/dist/file/writeFile.cjs +45 -21
- package/dist/file/writeFile.d.ts +37 -5
- package/dist/file/writeFile.mjs +35 -22
- package/dist/file/writeJsonFile.cjs +48 -27
- package/dist/file/writeJsonFile.d.ts +37 -6
- package/dist/file/writeJsonFile.mjs +39 -28
- package/dist/file/writeTextFile.cjs +45 -21
- package/dist/file/writeTextFile.d.ts +37 -5
- package/dist/file/writeTextFile.mjs +35 -22
- package/dist/implementor.cjs +8 -5
- package/dist/implementor.d.ts +4 -4
- package/dist/implementor.mjs +8 -5
- package/dist/index.cjs +2 -0
- package/dist/index.mjs +2 -1
- package/dist/override.d.ts +8 -0
- package/package.json +4 -4
- package/dist/dataStructure/constraint/exist.d.ts +0 -10
- package/dist/dataStructure/helper/exist.cjs +0 -7
- package/dist/dataStructure/helper/exist.d.ts +0 -2
- package/dist/dataStructure/helper/exist.mjs +0 -7
- package/dist/file/types/fileSystemEither.d.ts +0 -2
- package/dist/file/types/index.d.ts +0 -1
- /package/{README → README.md} +0 -0
|
@@ -9,5 +9,9 @@ var __exportAll = (all, no_symbols) => {
|
|
|
9
9
|
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
10
10
|
return target;
|
|
11
11
|
};
|
|
12
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { get: (a, b) => (typeof require !== "undefined" ? require : a)[b] }) : x)(function(x) {
|
|
13
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
14
|
+
throw Error("Calling `require` for \"" + x + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
|
|
15
|
+
});
|
|
12
16
|
//#endregion
|
|
13
|
-
export { __exportAll };
|
|
17
|
+
export { __exportAll, __require };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Error, SymbolCommandError } from './error';
|
|
2
|
-
import { EligibleType } from './types';
|
|
2
|
+
import { EligibleType, ForbiddenInvalidIdentifier } from './types';
|
|
3
3
|
import type * as DCommon from "@duplojs/lang/common";
|
|
4
4
|
import type * as DKind from "@duplojs/lang/kind";
|
|
5
5
|
import type * as DDataStructure from "@duplojs/lang/dataStructure";
|
|
@@ -15,4 +15,4 @@ export interface CreateArgumentParams {
|
|
|
15
15
|
readonly description?: string;
|
|
16
16
|
readonly optional?: boolean;
|
|
17
17
|
}
|
|
18
|
-
export declare function createArgument<GenericName extends string, GenericStructure extends DDataStructure.Structure<EligibleType>, GenericValue extends DDataStructure.StructureValue<GenericStructure>, const GenericParams extends CreateArgumentParams = {}>(name: GenericName
|
|
18
|
+
export declare function createArgument<GenericName extends string, GenericStructure extends DDataStructure.Structure<EligibleType>, GenericValue extends DDataStructure.StructureValue<GenericStructure>, const GenericParams extends CreateArgumentParams = {}>(name: GenericName & ForbiddenInvalidIdentifier<GenericName>, dataStructure: GenericStructure, params?: GenericParams): Argument<GenericName, (GenericValue | (DCommon.IsEqual<GenericParams["optional"], true> extends true ? undefined : never))>;
|
package/dist/command/create.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
2
2
|
const require_kind = require("./kind.cjs");
|
|
3
3
|
const require_error = require("./error.cjs");
|
|
4
|
+
const require_base = require("./options/base.cjs");
|
|
4
5
|
const require_help = require("./help.cjs");
|
|
5
6
|
let _duplojs_lang_common = require("@duplojs/lang/common");
|
|
6
7
|
_duplojs_lang_common = require_runtime.__toESM(_duplojs_lang_common, 1);
|
|
@@ -51,19 +52,23 @@ function create(...args) {
|
|
|
51
52
|
}
|
|
52
53
|
const commandOptions = await _duplojs_lang_generator.asyncReduce(self.options, _duplojs_lang_generator.reduceFrom({
|
|
53
54
|
options: {},
|
|
54
|
-
restArgs: args
|
|
55
|
-
|
|
55
|
+
restArgs: args,
|
|
56
|
+
hasError: false
|
|
57
|
+
}), async ({ item: option, lastValue, next }) => {
|
|
56
58
|
const optionResult = await option.execute(lastValue.restArgs, error);
|
|
57
|
-
if (optionResult === require_error.SymbolCommandError) return
|
|
59
|
+
if (optionResult === require_error.SymbolCommandError) return next(_duplojs_lang_object.override(lastValue, { hasError: true }));
|
|
58
60
|
return next({
|
|
59
61
|
options: _duplojs_lang_object.override(lastValue.options, { [option.name]: optionResult.result }),
|
|
60
|
-
restArgs: optionResult.argumentRest
|
|
62
|
+
restArgs: optionResult.argumentRest,
|
|
63
|
+
hasError: lastValue.hasError
|
|
61
64
|
});
|
|
62
65
|
});
|
|
63
|
-
if (commandOptions ===
|
|
66
|
+
if (commandOptions.hasError === true) return require_error.SymbolCommandError;
|
|
67
|
+
const unknownOptions = _duplojs_lang_array.filter(commandOptions.restArgs, require_base.isOptionToken);
|
|
68
|
+
if (unknownOptions.length > 0) return error.addUnknownOptionIssue(unknownOptions);
|
|
64
69
|
if (self.subject?.type === "argument") {
|
|
65
|
-
if (self.subject.args.length
|
|
66
|
-
const
|
|
70
|
+
if (self.subject.args.length < commandOptions.restArgs.length) return error.addTooMuchCommandArgumentIssue(self.subject.args.length, commandOptions.restArgs.length);
|
|
71
|
+
const commandArgs = await _duplojs_lang_generator.asyncReduce(self.subject.args, _duplojs_lang_generator.reduceFrom({
|
|
67
72
|
args: {},
|
|
68
73
|
restArgs: commandOptions.restArgs
|
|
69
74
|
}), async ({ item: argument, lastValue, next, exit }) => {
|
|
@@ -75,13 +80,16 @@ function create(...args) {
|
|
|
75
80
|
restArgs: _duplojs_lang_array.shift(lastValue.restArgs)
|
|
76
81
|
});
|
|
77
82
|
});
|
|
78
|
-
if (
|
|
83
|
+
if (commandArgs === require_error.SymbolCommandError) return require_error.SymbolCommandError;
|
|
79
84
|
await execute({
|
|
80
85
|
options: commandOptions.options,
|
|
81
|
-
args:
|
|
86
|
+
args: commandArgs.args
|
|
82
87
|
});
|
|
83
88
|
} else {
|
|
84
|
-
if (commandOptions.restArgs.length > 0)
|
|
89
|
+
if (commandOptions.restArgs.length > 0) {
|
|
90
|
+
if (self.subject?.type === "subCommand") return error.addUnknownSubCommandIssue(commandOptions.restArgs[0]);
|
|
91
|
+
return error.addTooMuchCommandArgumentIssue(0, commandOptions.restArgs.length);
|
|
92
|
+
}
|
|
85
93
|
await execute({ options: commandOptions.options });
|
|
86
94
|
}
|
|
87
95
|
},
|
package/dist/command/create.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Option } from './options';
|
|
2
2
|
import { SymbolCommandError, Error } from './error';
|
|
3
3
|
import { Argument } from './argument';
|
|
4
|
-
import { ForbiddenDuplicateName } from './types';
|
|
4
|
+
import { ForbiddenDuplicateName, ForbiddenInvalidIdentifier } from './types';
|
|
5
5
|
import * as DCommon from "@duplojs/lang/common";
|
|
6
6
|
import type * as DKind from "@duplojs/lang/kind";
|
|
7
7
|
declare const commandKind: DKind.Handler<DKind.Definition<"@DuplojsServerCommand/command", unknown>>;
|
|
@@ -42,6 +42,6 @@ export type CreateCommandExecuteParams<GenericOptions extends DCommon.AnyTuple<O
|
|
|
42
42
|
readonly [GenericArgument in GenericArguments[number] as GenericArgument["name"]]: Exclude<Awaited<ReturnType<GenericArgument["execute"]>>, SymbolCommandError>;
|
|
43
43
|
};
|
|
44
44
|
}));
|
|
45
|
-
export declare function create<GenericName extends string>(name: GenericName
|
|
46
|
-
export declare function create<GenericName extends string, const GenericOptions extends DCommon.AnyTuple<Option> = never, GenericSubjects extends Subjects = never>(name: GenericName
|
|
45
|
+
export declare function create<GenericName extends string>(name: GenericName & ForbiddenInvalidIdentifier<GenericName>, execute: () => void): Command<GenericName>;
|
|
46
|
+
export declare function create<GenericName extends string, const GenericOptions extends DCommon.AnyTuple<Option> = never, GenericSubjects extends Subjects = never>(name: GenericName & ForbiddenInvalidIdentifier<GenericName>, params: CreateCommandParams<GenericOptions, GenericSubjects>, execute: (params: CreateCommandExecuteParams<GenericOptions, Extract<GenericSubjects, DCommon.AnyTuple<Argument>>>) => DCommon.MaybePromise<void>): Command<GenericName>;
|
|
47
47
|
export {};
|
package/dist/command/create.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createKind } from "./kind.mjs";
|
|
2
2
|
import { SymbolCommandError } from "./error.mjs";
|
|
3
|
+
import { isOptionToken } from "./options/base.mjs";
|
|
3
4
|
import { helpOption, logCommandHelp } from "./help.mjs";
|
|
4
5
|
import * as DCommon from "@duplojs/lang/common";
|
|
5
6
|
import * as DObject from "@duplojs/lang/object";
|
|
@@ -46,19 +47,23 @@ function create(...args) {
|
|
|
46
47
|
}
|
|
47
48
|
const commandOptions = await DGenerator.asyncReduce(self.options, DGenerator.reduceFrom({
|
|
48
49
|
options: {},
|
|
49
|
-
restArgs: args
|
|
50
|
-
|
|
50
|
+
restArgs: args,
|
|
51
|
+
hasError: false
|
|
52
|
+
}), async ({ item: option, lastValue, next }) => {
|
|
51
53
|
const optionResult = await option.execute(lastValue.restArgs, error);
|
|
52
|
-
if (optionResult === SymbolCommandError) return
|
|
54
|
+
if (optionResult === SymbolCommandError) return next(DObject.override(lastValue, { hasError: true }));
|
|
53
55
|
return next({
|
|
54
56
|
options: DObject.override(lastValue.options, { [option.name]: optionResult.result }),
|
|
55
|
-
restArgs: optionResult.argumentRest
|
|
57
|
+
restArgs: optionResult.argumentRest,
|
|
58
|
+
hasError: lastValue.hasError
|
|
56
59
|
});
|
|
57
60
|
});
|
|
58
|
-
if (commandOptions ===
|
|
61
|
+
if (commandOptions.hasError === true) return SymbolCommandError;
|
|
62
|
+
const unknownOptions = DArray.filter(commandOptions.restArgs, isOptionToken);
|
|
63
|
+
if (unknownOptions.length > 0) return error.addUnknownOptionIssue(unknownOptions);
|
|
59
64
|
if (self.subject?.type === "argument") {
|
|
60
|
-
if (self.subject.args.length
|
|
61
|
-
const
|
|
65
|
+
if (self.subject.args.length < commandOptions.restArgs.length) return error.addTooMuchCommandArgumentIssue(self.subject.args.length, commandOptions.restArgs.length);
|
|
66
|
+
const commandArgs = await DGenerator.asyncReduce(self.subject.args, DGenerator.reduceFrom({
|
|
62
67
|
args: {},
|
|
63
68
|
restArgs: commandOptions.restArgs
|
|
64
69
|
}), async ({ item: argument, lastValue, next, exit }) => {
|
|
@@ -70,13 +75,16 @@ function create(...args) {
|
|
|
70
75
|
restArgs: DArray.shift(lastValue.restArgs)
|
|
71
76
|
});
|
|
72
77
|
});
|
|
73
|
-
if (
|
|
78
|
+
if (commandArgs === SymbolCommandError) return SymbolCommandError;
|
|
74
79
|
await execute({
|
|
75
80
|
options: commandOptions.options,
|
|
76
|
-
args:
|
|
81
|
+
args: commandArgs.args
|
|
77
82
|
});
|
|
78
83
|
} else {
|
|
79
|
-
if (commandOptions.restArgs.length > 0)
|
|
84
|
+
if (commandOptions.restArgs.length > 0) {
|
|
85
|
+
if (self.subject?.type === "subCommand") return error.addUnknownSubCommandIssue(commandOptions.restArgs[0]);
|
|
86
|
+
return error.addTooMuchCommandArgumentIssue(0, commandOptions.restArgs.length);
|
|
87
|
+
}
|
|
80
88
|
await execute({ options: commandOptions.options });
|
|
81
89
|
}
|
|
82
90
|
},
|
package/dist/command/error.cjs
CHANGED
|
@@ -2,12 +2,12 @@ const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
|
2
2
|
const require_defaultInterpreter = require("../dataStructure/common/error/defaultInterpreter.cjs");
|
|
3
3
|
let _duplojs_lang_common = require("@duplojs/lang/common");
|
|
4
4
|
_duplojs_lang_common = require_runtime.__toESM(_duplojs_lang_common, 1);
|
|
5
|
+
let _duplojs_lang_pattern = require("@duplojs/lang/pattern");
|
|
6
|
+
_duplojs_lang_pattern = require_runtime.__toESM(_duplojs_lang_pattern, 1);
|
|
5
7
|
let _duplojs_lang_dataStructure = require("@duplojs/lang/dataStructure");
|
|
6
8
|
_duplojs_lang_dataStructure = require_runtime.__toESM(_duplojs_lang_dataStructure, 1);
|
|
7
9
|
let _duplojs_lang_array = require("@duplojs/lang/array");
|
|
8
10
|
_duplojs_lang_array = require_runtime.__toESM(_duplojs_lang_array, 1);
|
|
9
|
-
let _duplojs_lang_pattern = require("@duplojs/lang/pattern");
|
|
10
|
-
_duplojs_lang_pattern = require_runtime.__toESM(_duplojs_lang_pattern, 1);
|
|
11
11
|
let _duplojs_lang_string = require("@duplojs/lang/string");
|
|
12
12
|
_duplojs_lang_string = require_runtime.__toESM(_duplojs_lang_string, 1);
|
|
13
13
|
let _duplojs_lang_printer = require("@duplojs/lang/printer");
|
|
@@ -23,6 +23,20 @@ function createError(commandName) {
|
|
|
23
23
|
issues,
|
|
24
24
|
currentPath,
|
|
25
25
|
pushPath: (path) => void currentPath.push(path),
|
|
26
|
+
addUnknownOptionIssue: (optionTokens) => {
|
|
27
|
+
issues.push(_duplojs_lang_modeling.taggedObject("UnknownOptionIssue", {
|
|
28
|
+
optionTokens,
|
|
29
|
+
path: _duplojs_lang_string.join(currentPath, ".")
|
|
30
|
+
}));
|
|
31
|
+
return SymbolCommandError;
|
|
32
|
+
},
|
|
33
|
+
addUnknownSubCommandIssue: (subCommandName) => {
|
|
34
|
+
issues.push(_duplojs_lang_modeling.taggedObject("UnknownSubCommandIssue", {
|
|
35
|
+
subCommandName,
|
|
36
|
+
path: _duplojs_lang_string.join(currentPath, ".")
|
|
37
|
+
}));
|
|
38
|
+
return SymbolCommandError;
|
|
39
|
+
},
|
|
26
40
|
addRequiredOptionIssue: (optionName) => {
|
|
27
41
|
issues.push(_duplojs_lang_modeling.taggedObject("RequiredOptionIssue", {
|
|
28
42
|
optionName,
|
|
@@ -84,63 +98,102 @@ function createError(commandName) {
|
|
|
84
98
|
};
|
|
85
99
|
}
|
|
86
100
|
function interpretDataStructureError(error, dataStructureErrorInterpreter) {
|
|
87
|
-
return _duplojs_lang_common.pipe(dataStructureErrorInterpreter(error), _duplojs_lang_array.map(({ interpretedMessage, path }) => _duplojs_lang_printer.
|
|
88
|
-
_duplojs_lang_printer.indent(1),
|
|
101
|
+
return _duplojs_lang_common.pipe(dataStructureErrorInterpreter(error), _duplojs_lang_array.map(({ interpretedMessage, path }) => _duplojs_lang_printer.renderLine([
|
|
89
102
|
"↳ ",
|
|
90
103
|
_duplojs_lang_printer.colorizedBold(path || "<value>", "cyan"),
|
|
91
104
|
" : ",
|
|
92
105
|
_duplojs_lang_printer.colorizedBold(interpretedMessage.subSource ?? interpretedMessage.interpretedSubSource ?? interpretedMessage.source ?? interpretedMessage.interpretedSource ?? "unknown data structure error.", "red")
|
|
93
|
-
],
|
|
106
|
+
], {
|
|
107
|
+
joinCharacter: "",
|
|
108
|
+
indent: _duplojs_lang_printer.Indent.tab,
|
|
109
|
+
indentLevel: 1
|
|
110
|
+
})));
|
|
94
111
|
}
|
|
95
112
|
function interpretErrorIssues(issues, dataStructureErrorInterpreter) {
|
|
96
113
|
return _duplojs_lang_printer.renderParagraph([_duplojs_lang_array.map(issues, _duplojs_lang_pattern.matchWithTaggedObject({
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
_duplojs_lang_printer.
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
_duplojs_lang_printer.
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
114
|
+
UnknownOptionIssue: ({ optionTokens }) => [_duplojs_lang_printer.renderLine([_duplojs_lang_printer.colorizedBold("OPTION: ", "blue"), _duplojs_lang_string.join(optionTokens, ", ")], {
|
|
115
|
+
joinCharacter: "",
|
|
116
|
+
indent: _duplojs_lang_printer.Indent.tab,
|
|
117
|
+
indentLevel: 1
|
|
118
|
+
}), _duplojs_lang_printer.renderLine(["↳ Unknown Option"], {
|
|
119
|
+
indent: _duplojs_lang_printer.Indent.tab,
|
|
120
|
+
indentLevel: 1
|
|
121
|
+
})],
|
|
122
|
+
UnknownSubCommandIssue: ({ subCommandName }) => [_duplojs_lang_printer.renderLine([_duplojs_lang_printer.colorizedBold("SUB-COMMAND: ", "cyan"), subCommandName], {
|
|
123
|
+
joinCharacter: "",
|
|
124
|
+
indent: _duplojs_lang_printer.Indent.tab,
|
|
125
|
+
indentLevel: 1
|
|
126
|
+
}), _duplojs_lang_printer.renderLine(["↳ Unknown Sub-command"], {
|
|
127
|
+
indent: _duplojs_lang_printer.Indent.tab,
|
|
128
|
+
indentLevel: 1
|
|
129
|
+
})],
|
|
130
|
+
DataStructureArgumentIssue: ({ argumentName, dataStructureError }) => [_duplojs_lang_printer.renderLine([_duplojs_lang_printer.colorizedBold("ARGUMENT: ", "magenta"), `--${argumentName}`], {
|
|
131
|
+
joinCharacter: "",
|
|
132
|
+
indent: _duplojs_lang_printer.Indent.tab,
|
|
133
|
+
indentLevel: 1
|
|
134
|
+
}), interpretDataStructureError(dataStructureError, dataStructureErrorInterpreter)],
|
|
135
|
+
RequiredArgumentIssue: ({ argumentName }) => [_duplojs_lang_printer.renderLine([_duplojs_lang_printer.colorizedBold("ARGUMENT: ", "magenta"), argumentName], {
|
|
136
|
+
joinCharacter: "",
|
|
137
|
+
indent: _duplojs_lang_printer.Indent.tab,
|
|
138
|
+
indentLevel: 1
|
|
139
|
+
}), _duplojs_lang_printer.renderLine(["↳ Missing Argument"], {
|
|
140
|
+
indent: _duplojs_lang_printer.Indent.tab,
|
|
141
|
+
indentLevel: 1
|
|
142
|
+
})],
|
|
143
|
+
DataStructureOptionIssue: ({ optionName, dataStructureError }) => [_duplojs_lang_printer.renderLine([_duplojs_lang_printer.colorizedBold("OPTION: ", "blue"), `--${optionName}`], {
|
|
144
|
+
joinCharacter: "",
|
|
145
|
+
indent: _duplojs_lang_printer.Indent.tab,
|
|
146
|
+
indentLevel: 1
|
|
147
|
+
}), interpretDataStructureError(dataStructureError, dataStructureErrorInterpreter)],
|
|
148
|
+
RequiredOptionIssue: ({ optionName }) => [_duplojs_lang_printer.renderLine([_duplojs_lang_printer.colorizedBold("OPTION: ", "blue"), `--${optionName}`], {
|
|
149
|
+
joinCharacter: "",
|
|
150
|
+
indent: _duplojs_lang_printer.Indent.tab,
|
|
151
|
+
indentLevel: 1
|
|
152
|
+
}), _duplojs_lang_printer.renderLine(["↳ Missing Option"], {
|
|
153
|
+
indent: _duplojs_lang_printer.Indent.tab,
|
|
154
|
+
indentLevel: 1
|
|
155
|
+
})],
|
|
156
|
+
RequiredOptionValueIssue: ({ optionName }) => [_duplojs_lang_printer.renderLine([_duplojs_lang_printer.colorizedBold("OPTION: ", "blue"), `--${optionName}`], {
|
|
157
|
+
joinCharacter: "",
|
|
158
|
+
indent: _duplojs_lang_printer.Indent.tab,
|
|
159
|
+
indentLevel: 1
|
|
160
|
+
}), _duplojs_lang_printer.renderLine(["↳ Missing Option Value"], {
|
|
161
|
+
indent: _duplojs_lang_printer.Indent.tab,
|
|
162
|
+
indentLevel: 1
|
|
163
|
+
})],
|
|
164
|
+
UnexpectedOptionValueIssue: ({ optionName }) => [_duplojs_lang_printer.renderLine([_duplojs_lang_printer.colorizedBold("OPTION: ", "blue"), `--${optionName}`], {
|
|
165
|
+
joinCharacter: "",
|
|
166
|
+
indent: _duplojs_lang_printer.Indent.tab,
|
|
167
|
+
indentLevel: 1
|
|
168
|
+
}), _duplojs_lang_printer.renderLine(["↳ Unexpected Value At This Option"], {
|
|
169
|
+
indent: _duplojs_lang_printer.Indent.tab,
|
|
170
|
+
indentLevel: 1
|
|
171
|
+
})],
|
|
172
|
+
TooMuchCommandArgumentIssue: ({ expect, receive }) => [_duplojs_lang_printer.renderLine([" Too Much Arguments"], {
|
|
173
|
+
indent: _duplojs_lang_printer.Indent.tab,
|
|
174
|
+
indentLevel: 1
|
|
175
|
+
}), _duplojs_lang_printer.renderLine([` expect: ${expect} receive: ${receive}`], {
|
|
176
|
+
indent: _duplojs_lang_printer.Indent.tab,
|
|
177
|
+
indentLevel: 1
|
|
178
|
+
})]
|
|
128
179
|
})), issues.length === 0 && "No issue found"]);
|
|
129
180
|
}
|
|
130
181
|
const defaultDataStructureErrorInterpreter = _duplojs_lang_dataStructure.createErrorInterpreter(require_defaultInterpreter.defaultErrorInterpreterDataStructureDictionary, require_defaultInterpreter.defaultErrorInterpreterCodecDictionary);
|
|
131
182
|
function interpretExecCommandError(error, dataStructureErrorInterpreter) {
|
|
132
|
-
return _duplojs_lang_printer.renderParagraph([
|
|
183
|
+
return _duplojs_lang_printer.renderParagraph([
|
|
133
184
|
_duplojs_lang_printer.colorizedBold("Command failed", "red"),
|
|
134
|
-
_duplojs_lang_printer.
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
185
|
+
_duplojs_lang_printer.renderLine([_duplojs_lang_printer.colorizedBold("COMMAND: ", "cyan"), _duplojs_lang_string.join(error.currentPath, " ")], {
|
|
186
|
+
joinCharacter: "",
|
|
187
|
+
indent: _duplojs_lang_printer.Indent.tab,
|
|
188
|
+
indentLevel: 1
|
|
189
|
+
}),
|
|
190
|
+
interpretErrorIssues(error.issues, dataStructureErrorInterpreter ?? defaultDataStructureErrorInterpreter)
|
|
191
|
+
]);
|
|
139
192
|
}
|
|
140
193
|
function interpretExecOptionsError(error, dataStructureErrorInterpreter) {
|
|
141
194
|
return _duplojs_lang_printer.renderParagraph([
|
|
142
195
|
_duplojs_lang_printer.colorizedBold("Invalid options", "red"),
|
|
143
|
-
|
|
196
|
+
["", ""],
|
|
144
197
|
interpretErrorIssues(error.issues, dataStructureErrorInterpreter ?? defaultDataStructureErrorInterpreter)
|
|
145
198
|
]);
|
|
146
199
|
}
|
package/dist/command/error.d.ts
CHANGED
|
@@ -27,17 +27,25 @@ export interface DataStructureArgumentIssue extends ArgumentIssueBase, DModeling
|
|
|
27
27
|
export interface CommandArgumentIssueBase {
|
|
28
28
|
readonly path: string;
|
|
29
29
|
}
|
|
30
|
+
export interface UnknownOptionIssue extends CommandArgumentIssueBase, DModeling.ObjectTag<"UnknownOptionIssue"> {
|
|
31
|
+
readonly optionTokens: readonly string[];
|
|
32
|
+
}
|
|
33
|
+
export interface UnknownSubCommandIssue extends CommandArgumentIssueBase, DModeling.ObjectTag<"UnknownSubCommandIssue"> {
|
|
34
|
+
readonly subCommandName: string;
|
|
35
|
+
}
|
|
30
36
|
export interface TooMuchCommandArgumentIssue extends CommandArgumentIssueBase, DModeling.ObjectTag<"TooMuchCommandArgumentIssue"> {
|
|
31
37
|
readonly expect: number;
|
|
32
38
|
readonly receive: number;
|
|
33
39
|
}
|
|
34
|
-
export type Issues = (RequiredOptionIssue | RequiredOptionValueIssue | UnexpectedOptionValueIssue | DataStructureOptionIssue | RequiredArgumentIssue | DataStructureArgumentIssue | TooMuchCommandArgumentIssue);
|
|
40
|
+
export type Issues = (RequiredOptionIssue | RequiredOptionValueIssue | UnexpectedOptionValueIssue | DataStructureOptionIssue | RequiredArgumentIssue | DataStructureArgumentIssue | TooMuchCommandArgumentIssue | UnknownOptionIssue | UnknownSubCommandIssue);
|
|
35
41
|
export declare const SymbolCommandError: unique symbol;
|
|
36
42
|
export type SymbolCommandError = typeof SymbolCommandError;
|
|
37
43
|
export interface Error {
|
|
38
44
|
readonly issues: readonly Issues[];
|
|
39
45
|
readonly currentPath: readonly string[];
|
|
40
46
|
pushPath(path: string): void;
|
|
47
|
+
addUnknownOptionIssue(optionTokens: readonly string[]): SymbolCommandError;
|
|
48
|
+
addUnknownSubCommandIssue(subCommandName: string): SymbolCommandError;
|
|
41
49
|
addRequiredOptionIssue(optionName: string): SymbolCommandError;
|
|
42
50
|
addRequiredOptionValueIssue(optionName: string): SymbolCommandError;
|
|
43
51
|
addUnexpectedOptionValueIssue(optionName: string, data: unknown): SymbolCommandError;
|
package/dist/command/error.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { defaultErrorInterpreterCodecDictionary, defaultErrorInterpreterDataStructureDictionary } from "../dataStructure/common/error/defaultInterpreter.mjs";
|
|
2
2
|
import * as DCommon from "@duplojs/lang/common";
|
|
3
|
+
import * as DPattern from "@duplojs/lang/pattern";
|
|
3
4
|
import * as DDataStructure from "@duplojs/lang/dataStructure";
|
|
4
5
|
import * as DArray from "@duplojs/lang/array";
|
|
5
|
-
import * as DPattern from "@duplojs/lang/pattern";
|
|
6
6
|
import * as DString from "@duplojs/lang/string";
|
|
7
7
|
import * as DPrinter from "@duplojs/lang/printer";
|
|
8
8
|
import * as DModeling from "@duplojs/lang/modeling";
|
|
@@ -15,6 +15,20 @@ function createError(commandName) {
|
|
|
15
15
|
issues,
|
|
16
16
|
currentPath,
|
|
17
17
|
pushPath: (path) => void currentPath.push(path),
|
|
18
|
+
addUnknownOptionIssue: (optionTokens) => {
|
|
19
|
+
issues.push(DModeling.taggedObject("UnknownOptionIssue", {
|
|
20
|
+
optionTokens,
|
|
21
|
+
path: DString.join(currentPath, ".")
|
|
22
|
+
}));
|
|
23
|
+
return SymbolCommandError;
|
|
24
|
+
},
|
|
25
|
+
addUnknownSubCommandIssue: (subCommandName) => {
|
|
26
|
+
issues.push(DModeling.taggedObject("UnknownSubCommandIssue", {
|
|
27
|
+
subCommandName,
|
|
28
|
+
path: DString.join(currentPath, ".")
|
|
29
|
+
}));
|
|
30
|
+
return SymbolCommandError;
|
|
31
|
+
},
|
|
18
32
|
addRequiredOptionIssue: (optionName) => {
|
|
19
33
|
issues.push(DModeling.taggedObject("RequiredOptionIssue", {
|
|
20
34
|
optionName,
|
|
@@ -76,63 +90,102 @@ function createError(commandName) {
|
|
|
76
90
|
};
|
|
77
91
|
}
|
|
78
92
|
function interpretDataStructureError(error, dataStructureErrorInterpreter) {
|
|
79
|
-
return DCommon.pipe(dataStructureErrorInterpreter(error), DArray.map(({ interpretedMessage, path }) => DPrinter.
|
|
80
|
-
DPrinter.indent(1),
|
|
93
|
+
return DCommon.pipe(dataStructureErrorInterpreter(error), DArray.map(({ interpretedMessage, path }) => DPrinter.renderLine([
|
|
81
94
|
"↳ ",
|
|
82
95
|
DPrinter.colorizedBold(path || "<value>", "cyan"),
|
|
83
96
|
" : ",
|
|
84
97
|
DPrinter.colorizedBold(interpretedMessage.subSource ?? interpretedMessage.interpretedSubSource ?? interpretedMessage.source ?? interpretedMessage.interpretedSource ?? "unknown data structure error.", "red")
|
|
85
|
-
],
|
|
98
|
+
], {
|
|
99
|
+
joinCharacter: "",
|
|
100
|
+
indent: DPrinter.Indent.tab,
|
|
101
|
+
indentLevel: 1
|
|
102
|
+
})));
|
|
86
103
|
}
|
|
87
104
|
function interpretErrorIssues(issues, dataStructureErrorInterpreter) {
|
|
88
105
|
return DPrinter.renderParagraph([DArray.map(issues, DPattern.matchWithTaggedObject({
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
DPrinter.
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
DPrinter.
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
106
|
+
UnknownOptionIssue: ({ optionTokens }) => [DPrinter.renderLine([DPrinter.colorizedBold("OPTION: ", "blue"), DString.join(optionTokens, ", ")], {
|
|
107
|
+
joinCharacter: "",
|
|
108
|
+
indent: DPrinter.Indent.tab,
|
|
109
|
+
indentLevel: 1
|
|
110
|
+
}), DPrinter.renderLine(["↳ Unknown Option"], {
|
|
111
|
+
indent: DPrinter.Indent.tab,
|
|
112
|
+
indentLevel: 1
|
|
113
|
+
})],
|
|
114
|
+
UnknownSubCommandIssue: ({ subCommandName }) => [DPrinter.renderLine([DPrinter.colorizedBold("SUB-COMMAND: ", "cyan"), subCommandName], {
|
|
115
|
+
joinCharacter: "",
|
|
116
|
+
indent: DPrinter.Indent.tab,
|
|
117
|
+
indentLevel: 1
|
|
118
|
+
}), DPrinter.renderLine(["↳ Unknown Sub-command"], {
|
|
119
|
+
indent: DPrinter.Indent.tab,
|
|
120
|
+
indentLevel: 1
|
|
121
|
+
})],
|
|
122
|
+
DataStructureArgumentIssue: ({ argumentName, dataStructureError }) => [DPrinter.renderLine([DPrinter.colorizedBold("ARGUMENT: ", "magenta"), `--${argumentName}`], {
|
|
123
|
+
joinCharacter: "",
|
|
124
|
+
indent: DPrinter.Indent.tab,
|
|
125
|
+
indentLevel: 1
|
|
126
|
+
}), interpretDataStructureError(dataStructureError, dataStructureErrorInterpreter)],
|
|
127
|
+
RequiredArgumentIssue: ({ argumentName }) => [DPrinter.renderLine([DPrinter.colorizedBold("ARGUMENT: ", "magenta"), argumentName], {
|
|
128
|
+
joinCharacter: "",
|
|
129
|
+
indent: DPrinter.Indent.tab,
|
|
130
|
+
indentLevel: 1
|
|
131
|
+
}), DPrinter.renderLine(["↳ Missing Argument"], {
|
|
132
|
+
indent: DPrinter.Indent.tab,
|
|
133
|
+
indentLevel: 1
|
|
134
|
+
})],
|
|
135
|
+
DataStructureOptionIssue: ({ optionName, dataStructureError }) => [DPrinter.renderLine([DPrinter.colorizedBold("OPTION: ", "blue"), `--${optionName}`], {
|
|
136
|
+
joinCharacter: "",
|
|
137
|
+
indent: DPrinter.Indent.tab,
|
|
138
|
+
indentLevel: 1
|
|
139
|
+
}), interpretDataStructureError(dataStructureError, dataStructureErrorInterpreter)],
|
|
140
|
+
RequiredOptionIssue: ({ optionName }) => [DPrinter.renderLine([DPrinter.colorizedBold("OPTION: ", "blue"), `--${optionName}`], {
|
|
141
|
+
joinCharacter: "",
|
|
142
|
+
indent: DPrinter.Indent.tab,
|
|
143
|
+
indentLevel: 1
|
|
144
|
+
}), DPrinter.renderLine(["↳ Missing Option"], {
|
|
145
|
+
indent: DPrinter.Indent.tab,
|
|
146
|
+
indentLevel: 1
|
|
147
|
+
})],
|
|
148
|
+
RequiredOptionValueIssue: ({ optionName }) => [DPrinter.renderLine([DPrinter.colorizedBold("OPTION: ", "blue"), `--${optionName}`], {
|
|
149
|
+
joinCharacter: "",
|
|
150
|
+
indent: DPrinter.Indent.tab,
|
|
151
|
+
indentLevel: 1
|
|
152
|
+
}), DPrinter.renderLine(["↳ Missing Option Value"], {
|
|
153
|
+
indent: DPrinter.Indent.tab,
|
|
154
|
+
indentLevel: 1
|
|
155
|
+
})],
|
|
156
|
+
UnexpectedOptionValueIssue: ({ optionName }) => [DPrinter.renderLine([DPrinter.colorizedBold("OPTION: ", "blue"), `--${optionName}`], {
|
|
157
|
+
joinCharacter: "",
|
|
158
|
+
indent: DPrinter.Indent.tab,
|
|
159
|
+
indentLevel: 1
|
|
160
|
+
}), DPrinter.renderLine(["↳ Unexpected Value At This Option"], {
|
|
161
|
+
indent: DPrinter.Indent.tab,
|
|
162
|
+
indentLevel: 1
|
|
163
|
+
})],
|
|
164
|
+
TooMuchCommandArgumentIssue: ({ expect, receive }) => [DPrinter.renderLine([" Too Much Arguments"], {
|
|
165
|
+
indent: DPrinter.Indent.tab,
|
|
166
|
+
indentLevel: 1
|
|
167
|
+
}), DPrinter.renderLine([` expect: ${expect} receive: ${receive}`], {
|
|
168
|
+
indent: DPrinter.Indent.tab,
|
|
169
|
+
indentLevel: 1
|
|
170
|
+
})]
|
|
120
171
|
})), issues.length === 0 && "No issue found"]);
|
|
121
172
|
}
|
|
122
173
|
const defaultDataStructureErrorInterpreter = DDataStructure.createErrorInterpreter(defaultErrorInterpreterDataStructureDictionary, defaultErrorInterpreterCodecDictionary);
|
|
123
174
|
function interpretExecCommandError(error, dataStructureErrorInterpreter) {
|
|
124
|
-
return DPrinter.renderParagraph([
|
|
175
|
+
return DPrinter.renderParagraph([
|
|
125
176
|
DPrinter.colorizedBold("Command failed", "red"),
|
|
126
|
-
DPrinter.
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
177
|
+
DPrinter.renderLine([DPrinter.colorizedBold("COMMAND: ", "cyan"), DString.join(error.currentPath, " ")], {
|
|
178
|
+
joinCharacter: "",
|
|
179
|
+
indent: DPrinter.Indent.tab,
|
|
180
|
+
indentLevel: 1
|
|
181
|
+
}),
|
|
182
|
+
interpretErrorIssues(error.issues, dataStructureErrorInterpreter ?? defaultDataStructureErrorInterpreter)
|
|
183
|
+
]);
|
|
131
184
|
}
|
|
132
185
|
function interpretExecOptionsError(error, dataStructureErrorInterpreter) {
|
|
133
186
|
return DPrinter.renderParagraph([
|
|
134
187
|
DPrinter.colorizedBold("Invalid options", "red"),
|
|
135
|
-
|
|
188
|
+
["", ""],
|
|
136
189
|
interpretErrorIssues(error.issues, dataStructureErrorInterpreter ?? defaultDataStructureErrorInterpreter)
|
|
137
190
|
]);
|
|
138
191
|
}
|
package/dist/command/exec.d.ts
CHANGED
|
@@ -2,12 +2,13 @@ import { CreateCommandExecuteParams, CreateCommandParams, Subjects } from './cre
|
|
|
2
2
|
import { Error } from './error';
|
|
3
3
|
import { Option } from './options';
|
|
4
4
|
import { Argument } from './argument';
|
|
5
|
+
import { ForbiddenInvalidIdentifier } from './types';
|
|
5
6
|
import type * as DCommon from "@duplojs/lang/common";
|
|
6
7
|
import * as DEither from "@duplojs/lang/either";
|
|
7
8
|
import type * as DDataStructure from "@duplojs/lang/dataStructure";
|
|
8
|
-
export interface ExecCommandParams<GenericOptions extends DCommon.AnyTuple<Option> = DCommon.AnyTuple<Option>, GenericSubjects extends Subjects = Subjects> extends CreateCommandParams<GenericOptions, GenericSubjects> {
|
|
9
|
-
displayName?:
|
|
9
|
+
export interface ExecCommandParams<GenericOptions extends DCommon.AnyTuple<Option> = DCommon.AnyTuple<Option>, GenericSubjects extends Subjects = Subjects, GenericDisplayName extends string = string> extends CreateCommandParams<GenericOptions, GenericSubjects> {
|
|
10
|
+
displayName?: GenericDisplayName & ForbiddenInvalidIdentifier<GenericDisplayName>;
|
|
10
11
|
dataStructureErrorInterpreter?: DDataStructure.ErrorInterpreter;
|
|
11
12
|
}
|
|
12
13
|
export declare function exec(execute: () => void): Promise<DEither.Ok | DEither.Error<Error>>;
|
|
13
|
-
export declare function exec<const GenericOptions extends DCommon.AnyTuple<Option> = never, GenericSubjects extends Subjects = never>(params: ExecCommandParams<GenericOptions, GenericSubjects>, execute: (params: CreateCommandExecuteParams<GenericOptions, Extract<GenericSubjects, DCommon.AnyTuple<Argument>>>) => DCommon.MaybePromise<void>): Promise<DEither.Ok | DEither.Error<Error>>;
|
|
14
|
+
export declare function exec<const GenericOptions extends DCommon.AnyTuple<Option> = never, GenericSubjects extends Subjects = never, const GenericDisplayName extends string = string>(params: ExecCommandParams<GenericOptions, GenericSubjects, GenericDisplayName>, execute: (params: CreateCommandExecuteParams<GenericOptions, Extract<GenericSubjects, DCommon.AnyTuple<Argument>>>) => DCommon.MaybePromise<void>): Promise<DEither.Ok | DEither.Error<Error>>;
|