@navios/commander 1.0.0 → 1.2.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/CHANGELOG.md +35 -0
- package/README.md +22 -0
- package/dist/src/commander.factory.d.mts +59 -0
- package/dist/src/commander.factory.d.mts.map +1 -1
- package/dist/src/commands/help.command.d.mts.map +1 -1
- package/dist/src/decorators/command.decorator.d.mts +9 -2
- package/dist/src/decorators/command.decorator.d.mts.map +1 -1
- package/dist/src/legacy-compat/decorators/cli-module.decorator.d.mts +26 -0
- package/dist/src/legacy-compat/decorators/cli-module.decorator.d.mts.map +1 -0
- package/dist/src/legacy-compat/decorators/command.decorator.d.mts +34 -0
- package/dist/src/legacy-compat/decorators/command.decorator.d.mts.map +1 -0
- package/dist/src/legacy-compat/decorators/index.d.mts +3 -0
- package/dist/src/legacy-compat/decorators/index.d.mts.map +1 -0
- package/dist/src/legacy-compat/index.d.mts +28 -0
- package/dist/src/legacy-compat/index.d.mts.map +1 -0
- package/dist/src/overrides/help.command.d.mts +18 -0
- package/dist/src/overrides/help.command.d.mts.map +1 -0
- package/dist/src/tokens/help-command.token.d.mts +4 -0
- package/dist/src/tokens/help-command.token.d.mts.map +1 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/lib/cli-module.decorator-CkP22084.cjs +71 -0
- package/lib/cli-module.decorator-CkP22084.cjs.map +1 -0
- package/lib/cli-module.decorator-DGuGfpex.d.mts +411 -0
- package/lib/cli-module.decorator-DGuGfpex.d.mts.map +1 -0
- package/lib/cli-module.decorator-DVl8009Q.d.cts +213 -0
- package/lib/cli-module.decorator-DVl8009Q.d.cts.map +1 -0
- package/lib/cli-module.decorator-UGbtkRYc.mjs +66 -0
- package/lib/cli-module.decorator-UGbtkRYc.mjs.map +1 -0
- package/lib/command.decorator-DVLSAqYZ.mjs +135 -0
- package/lib/command.decorator-DVLSAqYZ.mjs.map +1 -0
- package/lib/command.decorator-UrNJmQN0.cjs +176 -0
- package/lib/command.decorator-UrNJmQN0.cjs.map +1 -0
- package/lib/help-command.token-C0Kgj60o.mjs +427 -0
- package/lib/help-command.token-C0Kgj60o.mjs.map +1 -0
- package/lib/help-command.token-CMWYI6em.cjs +438 -0
- package/lib/help-command.token-CMWYI6em.cjs.map +1 -0
- package/lib/help.command-DQyv6ali.cjs +317 -0
- package/lib/help.command-DQyv6ali.cjs.map +1 -0
- package/lib/help.command-dtZbhq0w.mjs +318 -0
- package/lib/help.command-dtZbhq0w.mjs.map +1 -0
- package/lib/index.cjs +45 -627
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +139 -281
- package/lib/index.d.cts.map +1 -1
- package/lib/index.d.mts +62 -402
- package/lib/index.d.mts.map +1 -1
- package/lib/index.mjs +30 -612
- package/lib/index.mjs.map +1 -1
- package/lib/legacy-compat/index.cjs +108 -0
- package/lib/legacy-compat/index.cjs.map +1 -0
- package/lib/legacy-compat/index.d.cts +63 -0
- package/lib/legacy-compat/index.d.cts.map +1 -0
- package/lib/legacy-compat/index.d.mts +63 -0
- package/lib/legacy-compat/index.d.mts.map +1 -0
- package/lib/legacy-compat/index.mjs +101 -0
- package/lib/legacy-compat/index.mjs.map +1 -0
- package/package.json +20 -3
- package/src/commander.factory.mts +107 -8
- package/src/commands/help.command.mts +4 -3
- package/src/decorators/command.decorator.mts +17 -8
- package/src/legacy-compat/decorators/cli-module.decorator.mts +46 -0
- package/src/legacy-compat/decorators/command.decorator.mts +46 -0
- package/src/legacy-compat/decorators/index.mts +2 -0
- package/src/legacy-compat/index.mts +31 -0
- package/src/overrides/help.command.mts +40 -0
- package/src/tokens/help-command.token.mts +5 -0
- package/tsconfig.json +0 -3
- package/tsconfig.spec.json +1 -1
- package/tsdown.config.mts +1 -1
- package/dist/src/commander.application.d.mts +0 -147
- package/dist/src/commander.application.d.mts.map +0 -1
- package/dist/src/metadata/cli-module.metadata.d.mts +0 -60
- package/dist/src/metadata/cli-module.metadata.d.mts.map +0 -1
- package/dist/src/services/module-loader.service.d.mts +0 -74
- package/dist/src/services/module-loader.service.d.mts.map +0 -1
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
const require_command_decorator = require('./command.decorator-UrNJmQN0.cjs');
|
|
2
|
+
const require_help_command_token = require('./help-command.token-CMWYI6em.cjs');
|
|
3
|
+
let _navios_core = require("@navios/core");
|
|
4
|
+
let zod = require("zod");
|
|
5
|
+
let _navios_commander_tui = require("@navios/commander-tui");
|
|
6
|
+
|
|
7
|
+
//#region src/overrides/help.command.mts
|
|
8
|
+
function applyDecs2203RFactory() {
|
|
9
|
+
function createAddInitializerMethod(initializers, decoratorFinishedRef) {
|
|
10
|
+
return function addInitializer(initializer) {
|
|
11
|
+
assertNotFinished(decoratorFinishedRef, "addInitializer");
|
|
12
|
+
assertCallable(initializer, "An initializer");
|
|
13
|
+
initializers.push(initializer);
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
|
|
17
|
+
var kindStr;
|
|
18
|
+
switch (kind) {
|
|
19
|
+
case 1:
|
|
20
|
+
kindStr = "accessor";
|
|
21
|
+
break;
|
|
22
|
+
case 2:
|
|
23
|
+
kindStr = "method";
|
|
24
|
+
break;
|
|
25
|
+
case 3:
|
|
26
|
+
kindStr = "getter";
|
|
27
|
+
break;
|
|
28
|
+
case 4:
|
|
29
|
+
kindStr = "setter";
|
|
30
|
+
break;
|
|
31
|
+
default: kindStr = "field";
|
|
32
|
+
}
|
|
33
|
+
var ctx = {
|
|
34
|
+
kind: kindStr,
|
|
35
|
+
name: isPrivate ? "#" + name : name,
|
|
36
|
+
static: isStatic,
|
|
37
|
+
private: isPrivate,
|
|
38
|
+
metadata
|
|
39
|
+
};
|
|
40
|
+
var decoratorFinishedRef = { v: false };
|
|
41
|
+
ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
|
|
42
|
+
var get, set;
|
|
43
|
+
if (kind === 0) if (isPrivate) {
|
|
44
|
+
get = desc.get;
|
|
45
|
+
set = desc.set;
|
|
46
|
+
} else {
|
|
47
|
+
get = function() {
|
|
48
|
+
return this[name];
|
|
49
|
+
};
|
|
50
|
+
set = function(v) {
|
|
51
|
+
this[name] = v;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
else if (kind === 2) get = function() {
|
|
55
|
+
return desc.value;
|
|
56
|
+
};
|
|
57
|
+
else {
|
|
58
|
+
if (kind === 1 || kind === 3) get = function() {
|
|
59
|
+
return desc.get.call(this);
|
|
60
|
+
};
|
|
61
|
+
if (kind === 1 || kind === 4) set = function(v) {
|
|
62
|
+
desc.set.call(this, v);
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
ctx.access = get && set ? {
|
|
66
|
+
get,
|
|
67
|
+
set
|
|
68
|
+
} : get ? { get } : { set };
|
|
69
|
+
try {
|
|
70
|
+
return dec(value, ctx);
|
|
71
|
+
} finally {
|
|
72
|
+
decoratorFinishedRef.v = true;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function assertNotFinished(decoratorFinishedRef, fnName) {
|
|
76
|
+
if (decoratorFinishedRef.v) throw new Error("attempted to call " + fnName + " after decoration was finished");
|
|
77
|
+
}
|
|
78
|
+
function assertCallable(fn, hint) {
|
|
79
|
+
if (typeof fn !== "function") throw new TypeError(hint + " must be a function");
|
|
80
|
+
}
|
|
81
|
+
function assertValidReturnValue(kind, value) {
|
|
82
|
+
var type = typeof value;
|
|
83
|
+
if (kind === 1) {
|
|
84
|
+
if (type !== "object" || value === null) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
85
|
+
if (value.get !== void 0) assertCallable(value.get, "accessor.get");
|
|
86
|
+
if (value.set !== void 0) assertCallable(value.set, "accessor.set");
|
|
87
|
+
if (value.init !== void 0) assertCallable(value.init, "accessor.init");
|
|
88
|
+
} else if (type !== "function") {
|
|
89
|
+
var hint;
|
|
90
|
+
if (kind === 0) hint = "field";
|
|
91
|
+
else if (kind === 10) hint = "class";
|
|
92
|
+
else hint = "method";
|
|
93
|
+
throw new TypeError(hint + " decorators must return a function or void 0");
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
|
|
97
|
+
var decs = decInfo[0];
|
|
98
|
+
var desc, init, value;
|
|
99
|
+
if (isPrivate) if (kind === 0 || kind === 1) desc = {
|
|
100
|
+
get: decInfo[3],
|
|
101
|
+
set: decInfo[4]
|
|
102
|
+
};
|
|
103
|
+
else if (kind === 3) desc = { get: decInfo[3] };
|
|
104
|
+
else if (kind === 4) desc = { set: decInfo[3] };
|
|
105
|
+
else desc = { value: decInfo[3] };
|
|
106
|
+
else if (kind !== 0) desc = Object.getOwnPropertyDescriptor(base, name);
|
|
107
|
+
if (kind === 1) value = {
|
|
108
|
+
get: desc.get,
|
|
109
|
+
set: desc.set
|
|
110
|
+
};
|
|
111
|
+
else if (kind === 2) value = desc.value;
|
|
112
|
+
else if (kind === 3) value = desc.get;
|
|
113
|
+
else if (kind === 4) value = desc.set;
|
|
114
|
+
var newValue, get, set;
|
|
115
|
+
if (typeof decs === "function") {
|
|
116
|
+
newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
|
|
117
|
+
if (newValue !== void 0) {
|
|
118
|
+
assertValidReturnValue(kind, newValue);
|
|
119
|
+
if (kind === 0) init = newValue;
|
|
120
|
+
else if (kind === 1) {
|
|
121
|
+
init = newValue.init;
|
|
122
|
+
get = newValue.get || value.get;
|
|
123
|
+
set = newValue.set || value.set;
|
|
124
|
+
value = {
|
|
125
|
+
get,
|
|
126
|
+
set
|
|
127
|
+
};
|
|
128
|
+
} else value = newValue;
|
|
129
|
+
}
|
|
130
|
+
} else for (var i = decs.length - 1; i >= 0; i--) {
|
|
131
|
+
var dec = decs[i];
|
|
132
|
+
newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
|
|
133
|
+
if (newValue !== void 0) {
|
|
134
|
+
assertValidReturnValue(kind, newValue);
|
|
135
|
+
var newInit;
|
|
136
|
+
if (kind === 0) newInit = newValue;
|
|
137
|
+
else if (kind === 1) {
|
|
138
|
+
newInit = newValue.init;
|
|
139
|
+
get = newValue.get || value.get;
|
|
140
|
+
set = newValue.set || value.set;
|
|
141
|
+
value = {
|
|
142
|
+
get,
|
|
143
|
+
set
|
|
144
|
+
};
|
|
145
|
+
} else value = newValue;
|
|
146
|
+
if (newInit !== void 0) if (init === void 0) init = newInit;
|
|
147
|
+
else if (typeof init === "function") init = [init, newInit];
|
|
148
|
+
else init.push(newInit);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
if (kind === 0 || kind === 1) {
|
|
152
|
+
if (init === void 0) init = function(instance, init$1) {
|
|
153
|
+
return init$1;
|
|
154
|
+
};
|
|
155
|
+
else if (typeof init !== "function") {
|
|
156
|
+
var ownInitializers = init;
|
|
157
|
+
init = function(instance, init$1) {
|
|
158
|
+
var value$1 = init$1;
|
|
159
|
+
for (var i$1 = 0; i$1 < ownInitializers.length; i$1++) value$1 = ownInitializers[i$1].call(instance, value$1);
|
|
160
|
+
return value$1;
|
|
161
|
+
};
|
|
162
|
+
} else {
|
|
163
|
+
var originalInitializer = init;
|
|
164
|
+
init = function(instance, init$1) {
|
|
165
|
+
return originalInitializer.call(instance, init$1);
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
ret.push(init);
|
|
169
|
+
}
|
|
170
|
+
if (kind !== 0) {
|
|
171
|
+
if (kind === 1) {
|
|
172
|
+
desc.get = value.get;
|
|
173
|
+
desc.set = value.set;
|
|
174
|
+
} else if (kind === 2) desc.value = value;
|
|
175
|
+
else if (kind === 3) desc.get = value;
|
|
176
|
+
else if (kind === 4) desc.set = value;
|
|
177
|
+
if (isPrivate) if (kind === 1) {
|
|
178
|
+
ret.push(function(instance, args) {
|
|
179
|
+
return value.get.call(instance, args);
|
|
180
|
+
});
|
|
181
|
+
ret.push(function(instance, args) {
|
|
182
|
+
return value.set.call(instance, args);
|
|
183
|
+
});
|
|
184
|
+
} else if (kind === 2) ret.push(value);
|
|
185
|
+
else ret.push(function(instance, args) {
|
|
186
|
+
return value.call(instance, args);
|
|
187
|
+
});
|
|
188
|
+
else Object.defineProperty(base, name, desc);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
function applyMemberDecs(Class, decInfos, metadata) {
|
|
192
|
+
var ret = [];
|
|
193
|
+
var protoInitializers;
|
|
194
|
+
var staticInitializers;
|
|
195
|
+
var existingProtoNonFields = /* @__PURE__ */ new Map();
|
|
196
|
+
var existingStaticNonFields = /* @__PURE__ */ new Map();
|
|
197
|
+
for (var i = 0; i < decInfos.length; i++) {
|
|
198
|
+
var decInfo = decInfos[i];
|
|
199
|
+
if (!Array.isArray(decInfo)) continue;
|
|
200
|
+
var kind = decInfo[1];
|
|
201
|
+
var name = decInfo[2];
|
|
202
|
+
var isPrivate = decInfo.length > 3;
|
|
203
|
+
var isStatic = kind >= 5;
|
|
204
|
+
var base;
|
|
205
|
+
var initializers;
|
|
206
|
+
if (isStatic) {
|
|
207
|
+
base = Class;
|
|
208
|
+
kind = kind - 5;
|
|
209
|
+
staticInitializers = staticInitializers || [];
|
|
210
|
+
initializers = staticInitializers;
|
|
211
|
+
} else {
|
|
212
|
+
base = Class.prototype;
|
|
213
|
+
protoInitializers = protoInitializers || [];
|
|
214
|
+
initializers = protoInitializers;
|
|
215
|
+
}
|
|
216
|
+
if (kind !== 0 && !isPrivate) {
|
|
217
|
+
var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
|
|
218
|
+
var existingKind = existingNonFields.get(name) || 0;
|
|
219
|
+
if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
|
|
220
|
+
else if (!existingKind && kind > 2) existingNonFields.set(name, kind);
|
|
221
|
+
else existingNonFields.set(name, true);
|
|
222
|
+
}
|
|
223
|
+
applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
|
|
224
|
+
}
|
|
225
|
+
pushInitializers(ret, protoInitializers);
|
|
226
|
+
pushInitializers(ret, staticInitializers);
|
|
227
|
+
return ret;
|
|
228
|
+
}
|
|
229
|
+
function pushInitializers(ret, initializers) {
|
|
230
|
+
if (initializers) ret.push(function(instance) {
|
|
231
|
+
for (var i = 0; i < initializers.length; i++) initializers[i].call(instance);
|
|
232
|
+
return instance;
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
function applyClassDecs(targetClass, classDecs, metadata) {
|
|
236
|
+
if (classDecs.length > 0) {
|
|
237
|
+
var initializers = [];
|
|
238
|
+
var newClass = targetClass;
|
|
239
|
+
var name = targetClass.name;
|
|
240
|
+
for (var i = classDecs.length - 1; i >= 0; i--) {
|
|
241
|
+
var decoratorFinishedRef = { v: false };
|
|
242
|
+
try {
|
|
243
|
+
var nextNewClass = classDecs[i](newClass, {
|
|
244
|
+
kind: "class",
|
|
245
|
+
name,
|
|
246
|
+
addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
|
|
247
|
+
metadata
|
|
248
|
+
});
|
|
249
|
+
} finally {
|
|
250
|
+
decoratorFinishedRef.v = true;
|
|
251
|
+
}
|
|
252
|
+
if (nextNewClass !== void 0) {
|
|
253
|
+
assertValidReturnValue(10, nextNewClass);
|
|
254
|
+
newClass = nextNewClass;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
return [defineMetadata(newClass, metadata), function() {
|
|
258
|
+
for (var i$1 = 0; i$1 < initializers.length; i$1++) initializers[i$1].call(newClass);
|
|
259
|
+
}];
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
function defineMetadata(Class, metadata) {
|
|
263
|
+
return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
|
|
264
|
+
configurable: true,
|
|
265
|
+
enumerable: true,
|
|
266
|
+
value: metadata
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
|
|
270
|
+
if (parentClass !== void 0) var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
|
|
271
|
+
var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
|
|
272
|
+
var e = applyMemberDecs(targetClass, memberDecs, metadata);
|
|
273
|
+
if (!classDecs.length) defineMetadata(targetClass, metadata);
|
|
274
|
+
return {
|
|
275
|
+
e,
|
|
276
|
+
get c() {
|
|
277
|
+
return applyClassDecs(targetClass, classDecs, metadata);
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
|
|
283
|
+
return (_apply_decs_2203_r = applyDecs2203RFactory())(targetClass, memberDecs, classDecs, parentClass);
|
|
284
|
+
}
|
|
285
|
+
var _dec, _initClass;
|
|
286
|
+
const helpOptionsSchema = zod.z.object({ command: zod.z.string().optional() });
|
|
287
|
+
let _HelpCommand;
|
|
288
|
+
_dec = require_command_decorator.Command({
|
|
289
|
+
token: require_help_command_token.HelpCommandToken,
|
|
290
|
+
path: "help",
|
|
291
|
+
description: "Show available commands or help for a specific command",
|
|
292
|
+
optionsSchema: helpOptionsSchema,
|
|
293
|
+
priority: 1e3
|
|
294
|
+
});
|
|
295
|
+
var HelpCommand = class {
|
|
296
|
+
static {
|
|
297
|
+
({c: [_HelpCommand, _initClass]} = _apply_decs_2203_r(this, [], [_dec]));
|
|
298
|
+
}
|
|
299
|
+
logger = (0, _navios_core.inject)(_navios_commander_tui.ScreenLogger, {
|
|
300
|
+
screen: {
|
|
301
|
+
name: "Help",
|
|
302
|
+
static: true
|
|
303
|
+
},
|
|
304
|
+
context: "Help"
|
|
305
|
+
});
|
|
306
|
+
commandRegistry = (0, _navios_core.inject)(require_help_command_token._CommandRegistryService);
|
|
307
|
+
async execute(options) {
|
|
308
|
+
if (options.command) this.logger.log(this.commandRegistry.formatCommandHelp(options.command));
|
|
309
|
+
else this.logger.log(this.commandRegistry.formatCommandList());
|
|
310
|
+
}
|
|
311
|
+
static {
|
|
312
|
+
_initClass();
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
//#endregion
|
|
317
|
+
//# sourceMappingURL=help.command-DQyv6ali.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help.command-DQyv6ali.cjs","names":["ScreenLogger","inject","z","Command","CommandRegistryService","HelpCommandToken","helpOptionsSchema","object","command","string","optional","token","path","description","optionsSchema","priority","HelpCommand","logger","screen","name","static","context","commandRegistry","execute","options","log","formatCommandHelp","formatCommandList"],"sources":["../src/overrides/help.command.mts"],"sourcesContent":["import { ScreenLogger } from '@navios/commander-tui'\nimport { inject } from '@navios/core'\nimport { z } from 'zod'\n\nimport { Command } from '../decorators/command.decorator.mjs'\nimport { CommandRegistryService } from '../services/command-registry.service.mjs'\nimport { HelpCommandToken } from '../tokens/help-command.token.mjs'\n\nimport type { CommandHandler } from '../interfaces/command-handler.interface.mjs'\n\nconst helpOptionsSchema = z.object({\n command: z.string().optional(),\n})\n\ntype HelpOptions = z.infer<typeof helpOptionsSchema>\n\n/**\n * Built-in help command that lists all available commands or shows help for a specific command.\n *\n * @public\n */\n@Command({\n token: HelpCommandToken,\n path: 'help',\n description: 'Show available commands or help for a specific command',\n optionsSchema: helpOptionsSchema,\n priority: 1000,\n})\nexport class HelpCommand implements CommandHandler<HelpOptions> {\n private logger = inject(ScreenLogger, { screen: { name: 'Help', static: true }, context: 'Help' })\n private commandRegistry = inject(CommandRegistryService)\n\n async execute(options: HelpOptions): Promise<void> {\n if (options.command) {\n this.logger.log(this.commandRegistry.formatCommandHelp(options.command))\n } else {\n this.logger.log(this.commandRegistry.formatCommandList())\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,MAAMM,oBAAoBJ,MAAEK,OAAO,EACjCC,SAASN,MAAEO,QAAM,CAAGC,UAAQ,EAC9B,CAAA;;OASCP,kCAAQ;CACPQ,OAAON;CACPO,MAAM;CACNC,aAAa;CACbC,eAAeR;CACfS,UAAU;CACZ,CAAA;AACO,IAAMC,cAAN,MAAMA;;;;CACHC,kCAAgBjB,oCAAc;EAAEkB,QAAQ;GAAEC,MAAM;GAAQC,QAAQ;GAAK;EAAGC,SAAS;EAAO,CAAA;CACxFC,2CAAyBlB,mDAAAA;CAEjC,MAAMmB,QAAQC,SAAqC;AACjD,MAAIA,QAAQhB,QACV,MAAKS,OAAOQ,IAAI,KAAKH,gBAAgBI,kBAAkBF,QAAQhB,QAAO,CAAA;MAEtE,MAAKS,OAAOQ,IAAI,KAAKH,gBAAgBK,mBAAiB,CAAA"}
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
import { t as Command } from "./command.decorator-DVLSAqYZ.mjs";
|
|
2
|
+
import { n as _CommandRegistryService, t as HelpCommandToken } from "./help-command.token-C0Kgj60o.mjs";
|
|
3
|
+
import { inject } from "@navios/core";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { ScreenLogger } from "@navios/commander-tui";
|
|
6
|
+
|
|
7
|
+
//#region src/overrides/help.command.mts
|
|
8
|
+
function applyDecs2203RFactory() {
|
|
9
|
+
function createAddInitializerMethod(initializers, decoratorFinishedRef) {
|
|
10
|
+
return function addInitializer(initializer) {
|
|
11
|
+
assertNotFinished(decoratorFinishedRef, "addInitializer");
|
|
12
|
+
assertCallable(initializer, "An initializer");
|
|
13
|
+
initializers.push(initializer);
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
|
|
17
|
+
var kindStr;
|
|
18
|
+
switch (kind) {
|
|
19
|
+
case 1:
|
|
20
|
+
kindStr = "accessor";
|
|
21
|
+
break;
|
|
22
|
+
case 2:
|
|
23
|
+
kindStr = "method";
|
|
24
|
+
break;
|
|
25
|
+
case 3:
|
|
26
|
+
kindStr = "getter";
|
|
27
|
+
break;
|
|
28
|
+
case 4:
|
|
29
|
+
kindStr = "setter";
|
|
30
|
+
break;
|
|
31
|
+
default: kindStr = "field";
|
|
32
|
+
}
|
|
33
|
+
var ctx = {
|
|
34
|
+
kind: kindStr,
|
|
35
|
+
name: isPrivate ? "#" + name : name,
|
|
36
|
+
static: isStatic,
|
|
37
|
+
private: isPrivate,
|
|
38
|
+
metadata
|
|
39
|
+
};
|
|
40
|
+
var decoratorFinishedRef = { v: false };
|
|
41
|
+
ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
|
|
42
|
+
var get, set;
|
|
43
|
+
if (kind === 0) if (isPrivate) {
|
|
44
|
+
get = desc.get;
|
|
45
|
+
set = desc.set;
|
|
46
|
+
} else {
|
|
47
|
+
get = function() {
|
|
48
|
+
return this[name];
|
|
49
|
+
};
|
|
50
|
+
set = function(v) {
|
|
51
|
+
this[name] = v;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
else if (kind === 2) get = function() {
|
|
55
|
+
return desc.value;
|
|
56
|
+
};
|
|
57
|
+
else {
|
|
58
|
+
if (kind === 1 || kind === 3) get = function() {
|
|
59
|
+
return desc.get.call(this);
|
|
60
|
+
};
|
|
61
|
+
if (kind === 1 || kind === 4) set = function(v) {
|
|
62
|
+
desc.set.call(this, v);
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
ctx.access = get && set ? {
|
|
66
|
+
get,
|
|
67
|
+
set
|
|
68
|
+
} : get ? { get } : { set };
|
|
69
|
+
try {
|
|
70
|
+
return dec(value, ctx);
|
|
71
|
+
} finally {
|
|
72
|
+
decoratorFinishedRef.v = true;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function assertNotFinished(decoratorFinishedRef, fnName) {
|
|
76
|
+
if (decoratorFinishedRef.v) throw new Error("attempted to call " + fnName + " after decoration was finished");
|
|
77
|
+
}
|
|
78
|
+
function assertCallable(fn, hint) {
|
|
79
|
+
if (typeof fn !== "function") throw new TypeError(hint + " must be a function");
|
|
80
|
+
}
|
|
81
|
+
function assertValidReturnValue(kind, value) {
|
|
82
|
+
var type = typeof value;
|
|
83
|
+
if (kind === 1) {
|
|
84
|
+
if (type !== "object" || value === null) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
85
|
+
if (value.get !== void 0) assertCallable(value.get, "accessor.get");
|
|
86
|
+
if (value.set !== void 0) assertCallable(value.set, "accessor.set");
|
|
87
|
+
if (value.init !== void 0) assertCallable(value.init, "accessor.init");
|
|
88
|
+
} else if (type !== "function") {
|
|
89
|
+
var hint;
|
|
90
|
+
if (kind === 0) hint = "field";
|
|
91
|
+
else if (kind === 10) hint = "class";
|
|
92
|
+
else hint = "method";
|
|
93
|
+
throw new TypeError(hint + " decorators must return a function or void 0");
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
|
|
97
|
+
var decs = decInfo[0];
|
|
98
|
+
var desc, init, value;
|
|
99
|
+
if (isPrivate) if (kind === 0 || kind === 1) desc = {
|
|
100
|
+
get: decInfo[3],
|
|
101
|
+
set: decInfo[4]
|
|
102
|
+
};
|
|
103
|
+
else if (kind === 3) desc = { get: decInfo[3] };
|
|
104
|
+
else if (kind === 4) desc = { set: decInfo[3] };
|
|
105
|
+
else desc = { value: decInfo[3] };
|
|
106
|
+
else if (kind !== 0) desc = Object.getOwnPropertyDescriptor(base, name);
|
|
107
|
+
if (kind === 1) value = {
|
|
108
|
+
get: desc.get,
|
|
109
|
+
set: desc.set
|
|
110
|
+
};
|
|
111
|
+
else if (kind === 2) value = desc.value;
|
|
112
|
+
else if (kind === 3) value = desc.get;
|
|
113
|
+
else if (kind === 4) value = desc.set;
|
|
114
|
+
var newValue, get, set;
|
|
115
|
+
if (typeof decs === "function") {
|
|
116
|
+
newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
|
|
117
|
+
if (newValue !== void 0) {
|
|
118
|
+
assertValidReturnValue(kind, newValue);
|
|
119
|
+
if (kind === 0) init = newValue;
|
|
120
|
+
else if (kind === 1) {
|
|
121
|
+
init = newValue.init;
|
|
122
|
+
get = newValue.get || value.get;
|
|
123
|
+
set = newValue.set || value.set;
|
|
124
|
+
value = {
|
|
125
|
+
get,
|
|
126
|
+
set
|
|
127
|
+
};
|
|
128
|
+
} else value = newValue;
|
|
129
|
+
}
|
|
130
|
+
} else for (var i = decs.length - 1; i >= 0; i--) {
|
|
131
|
+
var dec = decs[i];
|
|
132
|
+
newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
|
|
133
|
+
if (newValue !== void 0) {
|
|
134
|
+
assertValidReturnValue(kind, newValue);
|
|
135
|
+
var newInit;
|
|
136
|
+
if (kind === 0) newInit = newValue;
|
|
137
|
+
else if (kind === 1) {
|
|
138
|
+
newInit = newValue.init;
|
|
139
|
+
get = newValue.get || value.get;
|
|
140
|
+
set = newValue.set || value.set;
|
|
141
|
+
value = {
|
|
142
|
+
get,
|
|
143
|
+
set
|
|
144
|
+
};
|
|
145
|
+
} else value = newValue;
|
|
146
|
+
if (newInit !== void 0) if (init === void 0) init = newInit;
|
|
147
|
+
else if (typeof init === "function") init = [init, newInit];
|
|
148
|
+
else init.push(newInit);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
if (kind === 0 || kind === 1) {
|
|
152
|
+
if (init === void 0) init = function(instance, init$1) {
|
|
153
|
+
return init$1;
|
|
154
|
+
};
|
|
155
|
+
else if (typeof init !== "function") {
|
|
156
|
+
var ownInitializers = init;
|
|
157
|
+
init = function(instance, init$1) {
|
|
158
|
+
var value$1 = init$1;
|
|
159
|
+
for (var i$1 = 0; i$1 < ownInitializers.length; i$1++) value$1 = ownInitializers[i$1].call(instance, value$1);
|
|
160
|
+
return value$1;
|
|
161
|
+
};
|
|
162
|
+
} else {
|
|
163
|
+
var originalInitializer = init;
|
|
164
|
+
init = function(instance, init$1) {
|
|
165
|
+
return originalInitializer.call(instance, init$1);
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
ret.push(init);
|
|
169
|
+
}
|
|
170
|
+
if (kind !== 0) {
|
|
171
|
+
if (kind === 1) {
|
|
172
|
+
desc.get = value.get;
|
|
173
|
+
desc.set = value.set;
|
|
174
|
+
} else if (kind === 2) desc.value = value;
|
|
175
|
+
else if (kind === 3) desc.get = value;
|
|
176
|
+
else if (kind === 4) desc.set = value;
|
|
177
|
+
if (isPrivate) if (kind === 1) {
|
|
178
|
+
ret.push(function(instance, args) {
|
|
179
|
+
return value.get.call(instance, args);
|
|
180
|
+
});
|
|
181
|
+
ret.push(function(instance, args) {
|
|
182
|
+
return value.set.call(instance, args);
|
|
183
|
+
});
|
|
184
|
+
} else if (kind === 2) ret.push(value);
|
|
185
|
+
else ret.push(function(instance, args) {
|
|
186
|
+
return value.call(instance, args);
|
|
187
|
+
});
|
|
188
|
+
else Object.defineProperty(base, name, desc);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
function applyMemberDecs(Class, decInfos, metadata) {
|
|
192
|
+
var ret = [];
|
|
193
|
+
var protoInitializers;
|
|
194
|
+
var staticInitializers;
|
|
195
|
+
var existingProtoNonFields = /* @__PURE__ */ new Map();
|
|
196
|
+
var existingStaticNonFields = /* @__PURE__ */ new Map();
|
|
197
|
+
for (var i = 0; i < decInfos.length; i++) {
|
|
198
|
+
var decInfo = decInfos[i];
|
|
199
|
+
if (!Array.isArray(decInfo)) continue;
|
|
200
|
+
var kind = decInfo[1];
|
|
201
|
+
var name = decInfo[2];
|
|
202
|
+
var isPrivate = decInfo.length > 3;
|
|
203
|
+
var isStatic = kind >= 5;
|
|
204
|
+
var base;
|
|
205
|
+
var initializers;
|
|
206
|
+
if (isStatic) {
|
|
207
|
+
base = Class;
|
|
208
|
+
kind = kind - 5;
|
|
209
|
+
staticInitializers = staticInitializers || [];
|
|
210
|
+
initializers = staticInitializers;
|
|
211
|
+
} else {
|
|
212
|
+
base = Class.prototype;
|
|
213
|
+
protoInitializers = protoInitializers || [];
|
|
214
|
+
initializers = protoInitializers;
|
|
215
|
+
}
|
|
216
|
+
if (kind !== 0 && !isPrivate) {
|
|
217
|
+
var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
|
|
218
|
+
var existingKind = existingNonFields.get(name) || 0;
|
|
219
|
+
if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
|
|
220
|
+
else if (!existingKind && kind > 2) existingNonFields.set(name, kind);
|
|
221
|
+
else existingNonFields.set(name, true);
|
|
222
|
+
}
|
|
223
|
+
applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
|
|
224
|
+
}
|
|
225
|
+
pushInitializers(ret, protoInitializers);
|
|
226
|
+
pushInitializers(ret, staticInitializers);
|
|
227
|
+
return ret;
|
|
228
|
+
}
|
|
229
|
+
function pushInitializers(ret, initializers) {
|
|
230
|
+
if (initializers) ret.push(function(instance) {
|
|
231
|
+
for (var i = 0; i < initializers.length; i++) initializers[i].call(instance);
|
|
232
|
+
return instance;
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
function applyClassDecs(targetClass, classDecs, metadata) {
|
|
236
|
+
if (classDecs.length > 0) {
|
|
237
|
+
var initializers = [];
|
|
238
|
+
var newClass = targetClass;
|
|
239
|
+
var name = targetClass.name;
|
|
240
|
+
for (var i = classDecs.length - 1; i >= 0; i--) {
|
|
241
|
+
var decoratorFinishedRef = { v: false };
|
|
242
|
+
try {
|
|
243
|
+
var nextNewClass = classDecs[i](newClass, {
|
|
244
|
+
kind: "class",
|
|
245
|
+
name,
|
|
246
|
+
addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
|
|
247
|
+
metadata
|
|
248
|
+
});
|
|
249
|
+
} finally {
|
|
250
|
+
decoratorFinishedRef.v = true;
|
|
251
|
+
}
|
|
252
|
+
if (nextNewClass !== void 0) {
|
|
253
|
+
assertValidReturnValue(10, nextNewClass);
|
|
254
|
+
newClass = nextNewClass;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
return [defineMetadata(newClass, metadata), function() {
|
|
258
|
+
for (var i$1 = 0; i$1 < initializers.length; i$1++) initializers[i$1].call(newClass);
|
|
259
|
+
}];
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
function defineMetadata(Class, metadata) {
|
|
263
|
+
return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
|
|
264
|
+
configurable: true,
|
|
265
|
+
enumerable: true,
|
|
266
|
+
value: metadata
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
|
|
270
|
+
if (parentClass !== void 0) var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
|
|
271
|
+
var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
|
|
272
|
+
var e = applyMemberDecs(targetClass, memberDecs, metadata);
|
|
273
|
+
if (!classDecs.length) defineMetadata(targetClass, metadata);
|
|
274
|
+
return {
|
|
275
|
+
e,
|
|
276
|
+
get c() {
|
|
277
|
+
return applyClassDecs(targetClass, classDecs, metadata);
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
|
|
283
|
+
return (_apply_decs_2203_r = applyDecs2203RFactory())(targetClass, memberDecs, classDecs, parentClass);
|
|
284
|
+
}
|
|
285
|
+
var _dec, _initClass;
|
|
286
|
+
const helpOptionsSchema = z.object({ command: z.string().optional() });
|
|
287
|
+
let _HelpCommand;
|
|
288
|
+
_dec = Command({
|
|
289
|
+
token: HelpCommandToken,
|
|
290
|
+
path: "help",
|
|
291
|
+
description: "Show available commands or help for a specific command",
|
|
292
|
+
optionsSchema: helpOptionsSchema,
|
|
293
|
+
priority: 1e3
|
|
294
|
+
});
|
|
295
|
+
var HelpCommand = class {
|
|
296
|
+
static {
|
|
297
|
+
({c: [_HelpCommand, _initClass]} = _apply_decs_2203_r(this, [], [_dec]));
|
|
298
|
+
}
|
|
299
|
+
logger = inject(ScreenLogger, {
|
|
300
|
+
screen: {
|
|
301
|
+
name: "Help",
|
|
302
|
+
static: true
|
|
303
|
+
},
|
|
304
|
+
context: "Help"
|
|
305
|
+
});
|
|
306
|
+
commandRegistry = inject(_CommandRegistryService);
|
|
307
|
+
async execute(options) {
|
|
308
|
+
if (options.command) this.logger.log(this.commandRegistry.formatCommandHelp(options.command));
|
|
309
|
+
else this.logger.log(this.commandRegistry.formatCommandList());
|
|
310
|
+
}
|
|
311
|
+
static {
|
|
312
|
+
_initClass();
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
//#endregion
|
|
317
|
+
export { };
|
|
318
|
+
//# sourceMappingURL=help.command-dtZbhq0w.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help.command-dtZbhq0w.mjs","names":["ScreenLogger","inject","z","Command","CommandRegistryService","HelpCommandToken","helpOptionsSchema","object","command","string","optional","token","path","description","optionsSchema","priority","HelpCommand","logger","screen","name","static","context","commandRegistry","execute","options","log","formatCommandHelp","formatCommandList"],"sources":["../src/overrides/help.command.mts"],"sourcesContent":["import { ScreenLogger } from '@navios/commander-tui'\nimport { inject } from '@navios/core'\nimport { z } from 'zod'\n\nimport { Command } from '../decorators/command.decorator.mjs'\nimport { CommandRegistryService } from '../services/command-registry.service.mjs'\nimport { HelpCommandToken } from '../tokens/help-command.token.mjs'\n\nimport type { CommandHandler } from '../interfaces/command-handler.interface.mjs'\n\nconst helpOptionsSchema = z.object({\n command: z.string().optional(),\n})\n\ntype HelpOptions = z.infer<typeof helpOptionsSchema>\n\n/**\n * Built-in help command that lists all available commands or shows help for a specific command.\n *\n * @public\n */\n@Command({\n token: HelpCommandToken,\n path: 'help',\n description: 'Show available commands or help for a specific command',\n optionsSchema: helpOptionsSchema,\n priority: 1000,\n})\nexport class HelpCommand implements CommandHandler<HelpOptions> {\n private logger = inject(ScreenLogger, { screen: { name: 'Help', static: true }, context: 'Help' })\n private commandRegistry = inject(CommandRegistryService)\n\n async execute(options: HelpOptions): Promise<void> {\n if (options.command) {\n this.logger.log(this.commandRegistry.formatCommandHelp(options.command))\n } else {\n this.logger.log(this.commandRegistry.formatCommandList())\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,MAAMM,oBAAoBJ,EAAEK,OAAO,EACjCC,SAASN,EAAEO,QAAM,CAAGC,UAAQ,EAC9B,CAAA;;OASCP,QAAQ;CACPQ,OAAON;CACPO,MAAM;CACNC,aAAa;CACbC,eAAeR;CACfS,UAAU;CACZ,CAAA;AACO,IAAMC,cAAN,MAAMA;;;;CACHC,SAAShB,OAAOD,cAAc;EAAEkB,QAAQ;GAAEC,MAAM;GAAQC,QAAQ;GAAK;EAAGC,SAAS;EAAO,CAAA;CACxFC,kBAAkBrB,OAAOG,wBAAAA;CAEjC,MAAMmB,QAAQC,SAAqC;AACjD,MAAIA,QAAQhB,QACV,MAAKS,OAAOQ,IAAI,KAAKH,gBAAgBI,kBAAkBF,QAAQhB,QAAO,CAAA;MAEtE,MAAKS,OAAOQ,IAAI,KAAKH,gBAAgBK,mBAAiB,CAAA"}
|