@navios/commander 1.0.0 → 1.1.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.
Files changed (42) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/src/commander.factory.d.mts +59 -0
  3. package/dist/src/commander.factory.d.mts.map +1 -1
  4. package/dist/src/commands/help.command.d.mts.map +1 -1
  5. package/dist/src/decorators/command.decorator.d.mts +9 -2
  6. package/dist/src/decorators/command.decorator.d.mts.map +1 -1
  7. package/dist/src/overrides/help.command.d.mts +18 -0
  8. package/dist/src/overrides/help.command.d.mts.map +1 -0
  9. package/dist/src/tokens/help-command.token.d.mts +4 -0
  10. package/dist/src/tokens/help-command.token.d.mts.map +1 -0
  11. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  12. package/dist/tsconfig.tsbuildinfo +1 -1
  13. package/lib/help-command.token-BPEgaaxY.mjs +558 -0
  14. package/lib/help-command.token-BPEgaaxY.mjs.map +1 -0
  15. package/lib/help-command.token-DcvTjwbA.cjs +611 -0
  16. package/lib/help-command.token-DcvTjwbA.cjs.map +1 -0
  17. package/lib/help.command-D9lsIDIe.cjs +316 -0
  18. package/lib/help.command-D9lsIDIe.cjs.map +1 -0
  19. package/lib/help.command-DtokRzad.mjs +317 -0
  20. package/lib/help.command-DtokRzad.mjs.map +1 -0
  21. package/lib/index.cjs +43 -566
  22. package/lib/index.cjs.map +1 -1
  23. package/lib/index.d.cts +184 -119
  24. package/lib/index.d.cts.map +1 -1
  25. package/lib/index.d.mts +184 -119
  26. package/lib/index.d.mts.map +1 -1
  27. package/lib/index.mjs +28 -551
  28. package/lib/index.mjs.map +1 -1
  29. package/package.json +10 -3
  30. package/src/commander.factory.mts +107 -8
  31. package/src/commands/help.command.mts +4 -3
  32. package/src/decorators/command.decorator.mts +17 -8
  33. package/src/overrides/help.command.mts +40 -0
  34. package/src/tokens/help-command.token.mts +5 -0
  35. package/tsconfig.json +0 -3
  36. package/tsconfig.spec.json +1 -1
  37. package/dist/src/commander.application.d.mts +0 -147
  38. package/dist/src/commander.application.d.mts.map +0 -1
  39. package/dist/src/metadata/cli-module.metadata.d.mts +0 -60
  40. package/dist/src/metadata/cli-module.metadata.d.mts.map +0 -1
  41. package/dist/src/services/module-loader.service.d.mts +0 -74
  42. package/dist/src/services/module-loader.service.d.mts.map +0 -1
package/lib/index.cjs CHANGED
@@ -1,556 +1,7 @@
1
+ const require_help_command_token = require('./help-command.token-DcvTjwbA.cjs');
1
2
  let _navios_core = require("@navios/core");
2
3
  let zod = require("zod");
3
4
 
4
- //#region src/metadata/command.metadata.mts
5
- /**
6
- * @internal
7
- * Symbol key used to store command metadata on classes.
8
- */ const CommandMetadataKey = Symbol("CommandMetadataKey");
9
- /**
10
- * Gets or creates command metadata for a class.
11
- *
12
- * @internal
13
- * @param target - The command class
14
- * @param context - The decorator context
15
- * @param path - The command path
16
- * @param description - Optional description for help text
17
- * @param optionsSchema - Optional Zod schema
18
- * @returns The command metadata
19
- */ function getCommandMetadata(target, context, path, description, optionsSchema) {
20
- if (context.metadata) {
21
- const metadata = context.metadata[CommandMetadataKey];
22
- if (metadata) return metadata;
23
- else {
24
- const newMetadata = {
25
- path,
26
- description,
27
- optionsSchema,
28
- customAttributes: /* @__PURE__ */ new Map()
29
- };
30
- context.metadata[CommandMetadataKey] = newMetadata;
31
- target[CommandMetadataKey] = newMetadata;
32
- return newMetadata;
33
- }
34
- }
35
- throw new Error("[Navios Commander] Wrong environment.");
36
- }
37
- /**
38
- * Extracts command metadata from a class.
39
- *
40
- * @param target - The command class
41
- * @returns The command metadata
42
- * @throws {Error} If the class is not decorated with @Command
43
- *
44
- * @example
45
- * ```typescript
46
- * const metadata = extractCommandMetadata(GreetCommand)
47
- * console.log(metadata.path) // 'greet'
48
- * ```
49
- */ function extractCommandMetadata(target) {
50
- const metadata = target[CommandMetadataKey];
51
- if (!metadata) throw new Error("[Navios Commander] Command metadata not found. Make sure to use @Command decorator.");
52
- return metadata;
53
- }
54
- /**
55
- * Checks if a class has command metadata.
56
- *
57
- * @param target - The class to check
58
- * @returns `true` if the class is decorated with @Command, `false` otherwise
59
- */ function hasCommandMetadata(target) {
60
- return !!target[CommandMetadataKey];
61
- }
62
-
63
- //#endregion
64
- //#region src/metadata/command-entry.metadata.mts
65
- /**
66
- * Symbol key for storing commands in ModuleMetadata.customEntries.
67
- * Used by @CliModule to store command classes.
68
- *
69
- * @public
70
- */ const CommandEntryKey = Symbol("CommandEntryKey");
71
- /**
72
- * Extracts commands from a module's metadata.
73
- * Returns empty set if no commands are defined.
74
- *
75
- * @param moduleClass - The module class decorated with @CliModule or @Module
76
- * @returns Set of command classes registered in the module
77
- *
78
- * @example
79
- * ```typescript
80
- * const commands = extractModuleCommands(AppModule)
81
- * for (const command of commands) {
82
- * console.log(command.name)
83
- * }
84
- * ```
85
- */ function extractModuleCommands(moduleClass) {
86
- return (0, _navios_core.extractModuleMetadata)(moduleClass).customEntries.get(CommandEntryKey) ?? /* @__PURE__ */ new Set();
87
- }
88
-
89
- //#endregion
90
- //#region src/decorators/command.decorator.mts
91
- /**
92
- * Decorator that marks a class as a CLI command.
93
- *
94
- * The decorated class must implement the `CommandHandler` interface with an `execute` method.
95
- * The command will be automatically registered when its module is loaded.
96
- *
97
- * @param options - Configuration options for the command
98
- * @returns A class decorator function
99
- *
100
- * @example
101
- * ```typescript
102
- * import { Command, CommandHandler } from '@navios/commander'
103
- * import { z } from 'zod'
104
- *
105
- * const optionsSchema = z.object({
106
- * name: z.string(),
107
- * greeting: z.string().optional().default('Hello')
108
- * })
109
- *
110
- * @Command({
111
- * path: 'greet',
112
- * optionsSchema: optionsSchema
113
- * })
114
- * export class GreetCommand implements CommandHandler<z.infer<typeof optionsSchema>> {
115
- * async execute(options) {
116
- * console.log(`${options.greeting}, ${options.name}!`)
117
- * }
118
- * }
119
- * ```
120
- */ function Command({ path, description, optionsSchema, priority, registry }) {
121
- return function(target, context) {
122
- if (context.kind !== "class") throw new Error("[Navios Commander] @Command decorator can only be used on classes.");
123
- const token = _navios_core.InjectionToken.create(target);
124
- if (context.metadata) getCommandMetadata(target, context, path, description, optionsSchema);
125
- return (0, _navios_core.Injectable)({
126
- token,
127
- scope: _navios_core.InjectableScope.Singleton,
128
- priority,
129
- registry
130
- })(target, context);
131
- };
132
- }
133
-
134
- //#endregion
135
- //#region src/services/command-registry.service.mts
136
- function applyDecs2203RFactory$3() {
137
- function createAddInitializerMethod(initializers, decoratorFinishedRef) {
138
- return function addInitializer(initializer) {
139
- assertNotFinished(decoratorFinishedRef, "addInitializer");
140
- assertCallable(initializer, "An initializer");
141
- initializers.push(initializer);
142
- };
143
- }
144
- function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
145
- var kindStr;
146
- switch (kind) {
147
- case 1:
148
- kindStr = "accessor";
149
- break;
150
- case 2:
151
- kindStr = "method";
152
- break;
153
- case 3:
154
- kindStr = "getter";
155
- break;
156
- case 4:
157
- kindStr = "setter";
158
- break;
159
- default: kindStr = "field";
160
- }
161
- var ctx = {
162
- kind: kindStr,
163
- name: isPrivate ? "#" + name : name,
164
- static: isStatic,
165
- private: isPrivate,
166
- metadata
167
- };
168
- var decoratorFinishedRef = { v: false };
169
- ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
170
- var get, set;
171
- if (kind === 0) if (isPrivate) {
172
- get = desc.get;
173
- set = desc.set;
174
- } else {
175
- get = function() {
176
- return this[name];
177
- };
178
- set = function(v) {
179
- this[name] = v;
180
- };
181
- }
182
- else if (kind === 2) get = function() {
183
- return desc.value;
184
- };
185
- else {
186
- if (kind === 1 || kind === 3) get = function() {
187
- return desc.get.call(this);
188
- };
189
- if (kind === 1 || kind === 4) set = function(v) {
190
- desc.set.call(this, v);
191
- };
192
- }
193
- ctx.access = get && set ? {
194
- get,
195
- set
196
- } : get ? { get } : { set };
197
- try {
198
- return dec(value, ctx);
199
- } finally {
200
- decoratorFinishedRef.v = true;
201
- }
202
- }
203
- function assertNotFinished(decoratorFinishedRef, fnName) {
204
- if (decoratorFinishedRef.v) throw new Error("attempted to call " + fnName + " after decoration was finished");
205
- }
206
- function assertCallable(fn, hint) {
207
- if (typeof fn !== "function") throw new TypeError(hint + " must be a function");
208
- }
209
- function assertValidReturnValue(kind, value) {
210
- var type = typeof value;
211
- if (kind === 1) {
212
- if (type !== "object" || value === null) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
213
- if (value.get !== void 0) assertCallable(value.get, "accessor.get");
214
- if (value.set !== void 0) assertCallable(value.set, "accessor.set");
215
- if (value.init !== void 0) assertCallable(value.init, "accessor.init");
216
- } else if (type !== "function") {
217
- var hint;
218
- if (kind === 0) hint = "field";
219
- else if (kind === 10) hint = "class";
220
- else hint = "method";
221
- throw new TypeError(hint + " decorators must return a function or void 0");
222
- }
223
- }
224
- function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
225
- var decs = decInfo[0];
226
- var desc, init, value;
227
- if (isPrivate) if (kind === 0 || kind === 1) desc = {
228
- get: decInfo[3],
229
- set: decInfo[4]
230
- };
231
- else if (kind === 3) desc = { get: decInfo[3] };
232
- else if (kind === 4) desc = { set: decInfo[3] };
233
- else desc = { value: decInfo[3] };
234
- else if (kind !== 0) desc = Object.getOwnPropertyDescriptor(base, name);
235
- if (kind === 1) value = {
236
- get: desc.get,
237
- set: desc.set
238
- };
239
- else if (kind === 2) value = desc.value;
240
- else if (kind === 3) value = desc.get;
241
- else if (kind === 4) value = desc.set;
242
- var newValue, get, set;
243
- if (typeof decs === "function") {
244
- newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
245
- if (newValue !== void 0) {
246
- assertValidReturnValue(kind, newValue);
247
- if (kind === 0) init = newValue;
248
- else if (kind === 1) {
249
- init = newValue.init;
250
- get = newValue.get || value.get;
251
- set = newValue.set || value.set;
252
- value = {
253
- get,
254
- set
255
- };
256
- } else value = newValue;
257
- }
258
- } else for (var i = decs.length - 1; i >= 0; i--) {
259
- var dec = decs[i];
260
- newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
261
- if (newValue !== void 0) {
262
- assertValidReturnValue(kind, newValue);
263
- var newInit;
264
- if (kind === 0) newInit = newValue;
265
- else if (kind === 1) {
266
- newInit = newValue.init;
267
- get = newValue.get || value.get;
268
- set = newValue.set || value.set;
269
- value = {
270
- get,
271
- set
272
- };
273
- } else value = newValue;
274
- if (newInit !== void 0) if (init === void 0) init = newInit;
275
- else if (typeof init === "function") init = [init, newInit];
276
- else init.push(newInit);
277
- }
278
- }
279
- if (kind === 0 || kind === 1) {
280
- if (init === void 0) init = function(instance, init$1) {
281
- return init$1;
282
- };
283
- else if (typeof init !== "function") {
284
- var ownInitializers = init;
285
- init = function(instance, init$1) {
286
- var value$1 = init$1;
287
- for (var i$1 = 0; i$1 < ownInitializers.length; i$1++) value$1 = ownInitializers[i$1].call(instance, value$1);
288
- return value$1;
289
- };
290
- } else {
291
- var originalInitializer = init;
292
- init = function(instance, init$1) {
293
- return originalInitializer.call(instance, init$1);
294
- };
295
- }
296
- ret.push(init);
297
- }
298
- if (kind !== 0) {
299
- if (kind === 1) {
300
- desc.get = value.get;
301
- desc.set = value.set;
302
- } else if (kind === 2) desc.value = value;
303
- else if (kind === 3) desc.get = value;
304
- else if (kind === 4) desc.set = value;
305
- if (isPrivate) if (kind === 1) {
306
- ret.push(function(instance, args) {
307
- return value.get.call(instance, args);
308
- });
309
- ret.push(function(instance, args) {
310
- return value.set.call(instance, args);
311
- });
312
- } else if (kind === 2) ret.push(value);
313
- else ret.push(function(instance, args) {
314
- return value.call(instance, args);
315
- });
316
- else Object.defineProperty(base, name, desc);
317
- }
318
- }
319
- function applyMemberDecs(Class, decInfos, metadata) {
320
- var ret = [];
321
- var protoInitializers;
322
- var staticInitializers;
323
- var existingProtoNonFields = /* @__PURE__ */ new Map();
324
- var existingStaticNonFields = /* @__PURE__ */ new Map();
325
- for (var i = 0; i < decInfos.length; i++) {
326
- var decInfo = decInfos[i];
327
- if (!Array.isArray(decInfo)) continue;
328
- var kind = decInfo[1];
329
- var name = decInfo[2];
330
- var isPrivate = decInfo.length > 3;
331
- var isStatic = kind >= 5;
332
- var base;
333
- var initializers;
334
- if (isStatic) {
335
- base = Class;
336
- kind = kind - 5;
337
- staticInitializers = staticInitializers || [];
338
- initializers = staticInitializers;
339
- } else {
340
- base = Class.prototype;
341
- protoInitializers = protoInitializers || [];
342
- initializers = protoInitializers;
343
- }
344
- if (kind !== 0 && !isPrivate) {
345
- var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
346
- var existingKind = existingNonFields.get(name) || 0;
347
- 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);
348
- else if (!existingKind && kind > 2) existingNonFields.set(name, kind);
349
- else existingNonFields.set(name, true);
350
- }
351
- applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
352
- }
353
- pushInitializers(ret, protoInitializers);
354
- pushInitializers(ret, staticInitializers);
355
- return ret;
356
- }
357
- function pushInitializers(ret, initializers) {
358
- if (initializers) ret.push(function(instance) {
359
- for (var i = 0; i < initializers.length; i++) initializers[i].call(instance);
360
- return instance;
361
- });
362
- }
363
- function applyClassDecs(targetClass, classDecs, metadata) {
364
- if (classDecs.length > 0) {
365
- var initializers = [];
366
- var newClass = targetClass;
367
- var name = targetClass.name;
368
- for (var i = classDecs.length - 1; i >= 0; i--) {
369
- var decoratorFinishedRef = { v: false };
370
- try {
371
- var nextNewClass = classDecs[i](newClass, {
372
- kind: "class",
373
- name,
374
- addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
375
- metadata
376
- });
377
- } finally {
378
- decoratorFinishedRef.v = true;
379
- }
380
- if (nextNewClass !== void 0) {
381
- assertValidReturnValue(10, nextNewClass);
382
- newClass = nextNewClass;
383
- }
384
- }
385
- return [defineMetadata(newClass, metadata), function() {
386
- for (var i$1 = 0; i$1 < initializers.length; i$1++) initializers[i$1].call(newClass);
387
- }];
388
- }
389
- }
390
- function defineMetadata(Class, metadata) {
391
- return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
392
- configurable: true,
393
- enumerable: true,
394
- value: metadata
395
- });
396
- }
397
- return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
398
- if (parentClass !== void 0) var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
399
- var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
400
- var e = applyMemberDecs(targetClass, memberDecs, metadata);
401
- if (!classDecs.length) defineMetadata(targetClass, metadata);
402
- return {
403
- e,
404
- get c() {
405
- return applyClassDecs(targetClass, classDecs, metadata);
406
- }
407
- };
408
- };
409
- }
410
- function _apply_decs_2203_r$3(targetClass, memberDecs, classDecs, parentClass) {
411
- return (_apply_decs_2203_r$3 = applyDecs2203RFactory$3())(targetClass, memberDecs, classDecs, parentClass);
412
- }
413
- var _dec$3, _initClass$3;
414
- let _CommandRegistryService;
415
- _dec$3 = (0, _navios_core.Injectable)();
416
- var CommandRegistryService = class {
417
- static {
418
- ({c: [_CommandRegistryService, _initClass$3]} = _apply_decs_2203_r$3(this, [], [_dec$3]));
419
- }
420
- commands = /* @__PURE__ */ new Map();
421
- /**
422
- * Register a command with its metadata.
423
- *
424
- * @param path - The command path (e.g., 'greet', 'user:create')
425
- * @param command - The registered command data
426
- * @throws Error if a command with the same path is already registered
427
- */ register(path, command) {
428
- if (this.commands.has(path)) throw new Error(`[Navios Commander] Duplicate command path: ${path}`);
429
- this.commands.set(path, command);
430
- }
431
- /**
432
- * Get a command by its path.
433
- *
434
- * @param path - The command path
435
- * @returns The registered command or undefined if not found
436
- */ getByPath(path) {
437
- return this.commands.get(path);
438
- }
439
- /**
440
- * Get all registered commands.
441
- *
442
- * @returns Map of path to registered command
443
- */ getAll() {
444
- return new Map(this.commands);
445
- }
446
- /**
447
- * Get all registered commands as an array of path and class pairs.
448
- * Useful for listing available commands.
449
- *
450
- * @returns Array of objects containing path and class
451
- */ getAllAsArray() {
452
- const result = [];
453
- for (const [path, { class: cls }] of this.commands) result.push({
454
- path,
455
- class: cls
456
- });
457
- return result;
458
- }
459
- /**
460
- * Formats help text listing all available commands with descriptions.
461
- *
462
- * @returns Formatted string listing all commands
463
- */ formatCommandList() {
464
- const lines = ["Available commands:", ""];
465
- for (const [path, { metadata }] of this.commands) {
466
- const description = metadata.description;
467
- if (description) lines.push(` ${path.padEnd(20)} ${description}`);
468
- else lines.push(` ${path}`);
469
- }
470
- return lines.join("\n");
471
- }
472
- /**
473
- * Formats help text for a specific command.
474
- *
475
- * @param commandPath - The command path to show help for
476
- * @returns Formatted string with command help
477
- */ formatCommandHelp(commandPath) {
478
- const command = this.commands.get(commandPath);
479
- if (!command) return `Unknown command: ${commandPath}\n\n${this.formatCommandList()}`;
480
- const { metadata } = command;
481
- const lines = [];
482
- lines.push(`Usage: ${metadata.path} [options]`);
483
- lines.push("");
484
- if (metadata.description) {
485
- lines.push(metadata.description);
486
- lines.push("");
487
- }
488
- if (metadata.optionsSchema) {
489
- lines.push("Options:");
490
- try {
491
- const shape = metadata.optionsSchema.def.shape;
492
- if (shape && typeof shape === "object") for (const [key, fieldSchema] of Object.entries(shape)) {
493
- const optionFlag = `--${key.replace(/([A-Z])/g, "-$1").toLowerCase()}`;
494
- const fieldType = this.getSchemaTypeName(fieldSchema);
495
- lines.push(` ${optionFlag.padEnd(20)} ${fieldType}`);
496
- }
497
- } catch {}
498
- }
499
- return lines.join("\n");
500
- }
501
- /**
502
- * Gets a human-readable type name from a Zod schema.
503
- */ getSchemaTypeName(schema) {
504
- try {
505
- let currentSchema = schema;
506
- let typeName = currentSchema?.def?.type;
507
- let isOptional = false;
508
- let defaultValue;
509
- while (typeName === "optional" || typeName === "default") {
510
- if (typeName === "optional") isOptional = true;
511
- if (typeName === "default") {
512
- isOptional = true;
513
- defaultValue = currentSchema?.def?.defaultValue?.();
514
- }
515
- currentSchema = currentSchema?.def?.innerType;
516
- typeName = currentSchema?.def?.type;
517
- }
518
- let result = `<${typeName || "unknown"}>`;
519
- if (defaultValue !== void 0) result += ` (default: ${JSON.stringify(defaultValue)})`;
520
- else if (isOptional) result += " (optional)";
521
- const description = this.getSchemaMeta(schema)?.description;
522
- if (description) result += ` - ${description}`;
523
- return result;
524
- } catch {
525
- return "<unknown>";
526
- }
527
- }
528
- /**
529
- * Gets metadata from a Zod schema, traversing innerType if needed.
530
- * Zod v4 stores meta at the outermost layer when .meta() is called last,
531
- * or in innerType when .meta() is called before .optional()/.default().
532
- */ getSchemaMeta(schema) {
533
- try {
534
- const directMeta = schema.meta?.();
535
- if (directMeta) return directMeta;
536
- const innerType = schema.def?.innerType;
537
- if (innerType) return this.getSchemaMeta(innerType);
538
- return;
539
- } catch {
540
- return;
541
- }
542
- }
543
- /**
544
- * Clear all registered commands.
545
- */ clear() {
546
- this.commands.clear();
547
- }
548
- static {
549
- _initClass$3();
550
- }
551
- };
552
-
553
- //#endregion
554
5
  //#region src/commands/help.command.mts
555
6
  function applyDecs2203RFactory$2() {
556
7
  function createAddInitializerMethod(initializers, decoratorFinishedRef) {
@@ -832,7 +283,8 @@ function _apply_decs_2203_r$2(targetClass, memberDecs, classDecs, parentClass) {
832
283
  var _dec$2, _initClass$2;
833
284
  const helpOptionsSchema = zod.z.object({ command: zod.z.string().optional() });
834
285
  let _HelpCommand;
835
- _dec$2 = Command({
286
+ _dec$2 = require_help_command_token.Command({
287
+ token: require_help_command_token.HelpCommandToken,
836
288
  path: "help",
837
289
  description: "Show available commands or help for a specific command",
838
290
  optionsSchema: helpOptionsSchema
@@ -842,7 +294,7 @@ var HelpCommand = class {
842
294
  ({c: [_HelpCommand, _initClass$2]} = _apply_decs_2203_r$2(this, [], [_dec$2]));
843
295
  }
844
296
  logger = (0, _navios_core.inject)(_navios_core.Logger, { context: "Commander" });
845
- commandRegistry = (0, _navios_core.inject)(_CommandRegistryService);
297
+ commandRegistry = (0, _navios_core.inject)(require_help_command_token._CommandRegistryService);
846
298
  async execute(options) {
847
299
  if (options.command) this.logger.log(this.commandRegistry.formatCommandHelp(options.command));
848
300
  else this.logger.log(this.commandRegistry.formatCommandList());
@@ -1692,7 +1144,7 @@ var CommanderAdapterService = class {
1692
1144
  ({c: [_CommanderAdapterService, _initClass]} = _apply_decs_2203_r(this, [], [_dec]));
1693
1145
  }
1694
1146
  container = (0, _navios_core.inject)(_navios_core.Container);
1695
- commandRegistry = (0, _navios_core.inject)(_CommandRegistryService);
1147
+ commandRegistry = (0, _navios_core.inject)(require_help_command_token._CommandRegistryService);
1696
1148
  cliParser = (0, _navios_core.inject)(_CliParserService);
1697
1149
  logger = (0, _navios_core.inject)(_navios_core.Logger, { context: "Commander" });
1698
1150
  options = {};
@@ -1709,14 +1161,14 @@ var CommanderAdapterService = class {
1709
1161
  */ async onModulesInit(modules) {
1710
1162
  this.registerBuiltInCommands();
1711
1163
  for (const [moduleName, metadata] of modules) {
1712
- const commands = metadata.customEntries.get(CommandEntryKey);
1164
+ const commands = metadata.customEntries.get(require_help_command_token.CommandEntryKey);
1713
1165
  if (!commands) continue;
1714
1166
  for (const commandClass of commands) {
1715
- if (!hasCommandMetadata(commandClass)) {
1167
+ if (!require_help_command_token.hasCommandMetadata(commandClass)) {
1716
1168
  this.logger.warn(`Class ${commandClass.name} in module ${moduleName} is listed in commands but has no @Command decorator. Skipping.`);
1717
1169
  continue;
1718
1170
  }
1719
- const commandMetadata = extractCommandMetadata(commandClass);
1171
+ const commandMetadata = require_help_command_token.extractCommandMetadata(commandClass);
1720
1172
  this.commandRegistry.register(commandMetadata.path, {
1721
1173
  class: commandClass,
1722
1174
  metadata: commandMetadata,
@@ -1728,7 +1180,7 @@ var CommanderAdapterService = class {
1728
1180
  /**
1729
1181
  * Registers built-in commands like help.
1730
1182
  */ registerBuiltInCommands() {
1731
- const helpMetadata = extractCommandMetadata(_HelpCommand);
1183
+ const helpMetadata = require_help_command_token.extractCommandMetadata(_HelpCommand);
1732
1184
  this.commandRegistry.register(helpMetadata.path, {
1733
1185
  class: _HelpCommand,
1734
1186
  metadata: helpMetadata,
@@ -1881,6 +1333,31 @@ var CommanderAdapterService = class {
1881
1333
  * await adapter.run(process.argv)
1882
1334
  * ```
1883
1335
  */ static async create(appModule, options = {}) {
1336
+ if (options.enableTUI) {
1337
+ let tuiModule;
1338
+ try {
1339
+ tuiModule = await import("@navios/commander-tui");
1340
+ } catch {
1341
+ throw new Error("TUI mode requires @navios/commander-tui package. Install it with: npm install @navios/commander-tui");
1342
+ }
1343
+ const { overrideConsoleLogger, ScreenManager } = tuiModule;
1344
+ overrideConsoleLogger(options.tuiOptions?.hideDefaultScreen ?? false);
1345
+ if (options.tuiOptions?.hideDefaultScreen) await Promise.resolve().then(() => require("./help.command-D9lsIDIe.cjs"));
1346
+ const app = await _navios_core.NaviosFactory.create(appModule, {
1347
+ adapter: defineCliEnvironment(),
1348
+ logger: options.logLevels
1349
+ });
1350
+ await (await app.get(ScreenManager)).bind({
1351
+ exitOnCtrlC: options.tuiOptions?.exitOnCtrlC,
1352
+ sidebarWidth: options.tuiOptions?.sidebarWidth,
1353
+ sidebarPosition: options.tuiOptions?.sidebarPosition,
1354
+ sidebarTitle: options.tuiOptions?.sidebarTitle,
1355
+ autoClose: options.tuiOptions?.autoClose,
1356
+ theme: options.tuiOptions?.theme,
1357
+ useMouse: options.tuiOptions?.useMouse
1358
+ });
1359
+ return app;
1360
+ }
1884
1361
  return await _navios_core.NaviosFactory.create(appModule, {
1885
1362
  adapter: defineCliEnvironment(),
1886
1363
  logger: _navios_core.ConsoleLogger.create({
@@ -1951,7 +1428,7 @@ var CommanderAdapterService = class {
1951
1428
  priority,
1952
1429
  registry
1953
1430
  })(target, context);
1954
- const commandSet = (0, _navios_core.getModuleCustomEntry)((0, _navios_core.getModuleMetadata)(target, context), CommandEntryKey, () => /* @__PURE__ */ new Set());
1431
+ const commandSet = (0, _navios_core.getModuleCustomEntry)((0, _navios_core.getModuleMetadata)(target, context), require_help_command_token.CommandEntryKey, () => /* @__PURE__ */ new Set());
1955
1432
  for (const command of commands) commandSet.add(command);
1956
1433
  return result;
1957
1434
  };
@@ -1965,14 +1442,14 @@ Object.defineProperty(exports, 'CliParserService', {
1965
1442
  return _CliParserService;
1966
1443
  }
1967
1444
  });
1968
- exports.Command = Command;
1969
- exports.CommandEntryKey = CommandEntryKey;
1445
+ exports.Command = require_help_command_token.Command;
1446
+ exports.CommandEntryKey = require_help_command_token.CommandEntryKey;
1970
1447
  exports.CommandExecutionContext = CommandExecutionContext;
1971
- exports.CommandMetadataKey = CommandMetadataKey;
1448
+ exports.CommandMetadataKey = require_help_command_token.CommandMetadataKey;
1972
1449
  Object.defineProperty(exports, 'CommandRegistryService', {
1973
1450
  enumerable: true,
1974
1451
  get: function () {
1975
- return _CommandRegistryService;
1452
+ return require_help_command_token._CommandRegistryService;
1976
1453
  }
1977
1454
  });
1978
1455
  Object.defineProperty(exports, 'CommanderAdapterService', {
@@ -1990,10 +1467,10 @@ Object.defineProperty(exports, 'HelpCommand', {
1990
1467
  }
1991
1468
  });
1992
1469
  exports.defineCliEnvironment = defineCliEnvironment;
1993
- exports.extractCommandMetadata = extractCommandMetadata;
1994
- exports.extractModuleCommands = extractModuleCommands;
1995
- exports.getCommandMetadata = getCommandMetadata;
1996
- exports.hasCommandMetadata = hasCommandMetadata;
1470
+ exports.extractCommandMetadata = require_help_command_token.extractCommandMetadata;
1471
+ exports.extractModuleCommands = require_help_command_token.extractModuleCommands;
1472
+ exports.getCommandMetadata = require_help_command_token.getCommandMetadata;
1473
+ exports.hasCommandMetadata = require_help_command_token.hasCommandMetadata;
1997
1474
  Object.keys(_navios_core).forEach(function (k) {
1998
1475
  if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
1999
1476
  enumerable: true,