@navios/commander 0.5.1 → 0.5.2

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/README.md CHANGED
@@ -129,6 +129,43 @@ export class UserModule {}
129
129
  export class AppModule {}
130
130
  ```
131
131
 
132
+ ### Accessing ExecutionContext
133
+
134
+ The `ExecutionContext` provides access to the current command execution information, including the module metadata, command metadata, command path, and options. This is useful for middleware, guards, or any service that needs context about the current command execution.
135
+
136
+ ```typescript
137
+ import { Command, CommandHandler, ExecutionContext } from '@navios/commander'
138
+ import { Injectable, inject } from '@navios/di'
139
+
140
+ @Injectable()
141
+ class CommandLogger {
142
+ private executionContext = inject(ExecutionContext)
143
+
144
+ logCommandInfo() {
145
+ const ctx = this.executionContext
146
+ console.log('Command Path:', ctx.getCommandPath())
147
+ console.log('Command Options:', ctx.getOptions())
148
+ console.log('Module:', ctx.getModule())
149
+ }
150
+ }
151
+
152
+ @Command({ path: 'example' })
153
+ export class ExampleCommand implements CommandHandler {
154
+ private logger = inject(CommandLogger)
155
+
156
+ async execute(options: any) {
157
+ this.logger.logCommandInfo()
158
+ // Your command logic here
159
+ }
160
+ }
161
+ ```
162
+
163
+ The `ExecutionContext` provides the following methods:
164
+ - `getModule()` - Returns the CLI module metadata
165
+ - `getCommand()` - Returns the command metadata
166
+ - `getCommandPath()` - Returns the command path (e.g., 'user:create')
167
+ - `getOptions()` - Returns the validated command options
168
+
132
169
  ### Listing All Commands
133
170
 
134
171
  ```typescript
@@ -1 +1 @@
1
- {"version":3,"file":"commander.application.d.mts","sourceRoot":"","sources":["../../src/commander.application.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAkB,MAAM,YAAY,CAAA;AAEvE,OAAO,EAAE,SAAS,EAAsB,MAAM,YAAY,CAAA;AAE1D,OAAO,KAAK,EAAkB,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAIpE,MAAM,WAAW,2BAA2B;CAAG;AAE/C,qB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OAGG;IACG,GAAG,CAAC,IAAI,GAAE,MAAM,EAAiB;IAgDjC,OAAO;IAMP,KAAK;CAGZ"}
@@ -5,4 +5,5 @@ export * from './decorators/index.mjs';
5
5
  export * from './interfaces/index.mjs';
6
6
  export * from './metadata/index.mjs';
7
7
  export * from './services/index.mjs';
8
+ export * from './tokens/index.mjs';
8
9
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/index.mts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,6BAA6B,CAAA;AAC3C,cAAc,yBAAyB,CAAA;AACvC,cAAc,wBAAwB,CAAA;AACtC,cAAc,wBAAwB,CAAA;AACtC,cAAc,sBAAsB,CAAA;AACpC,cAAc,sBAAsB,CAAA"}
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/index.mts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,6BAA6B,CAAA;AAC3C,cAAc,yBAAyB,CAAA;AACvC,cAAc,wBAAwB,CAAA;AACtC,cAAc,wBAAwB,CAAA;AACtC,cAAc,sBAAsB,CAAA;AACpC,cAAc,sBAAsB,CAAA;AACpC,cAAc,oBAAoB,CAAA"}
@@ -0,0 +1,11 @@
1
+ import type { CommandMetadata } from '../metadata/command.metadata.mjs';
2
+ export declare class CommanderExecutionContext {
3
+ private readonly command;
4
+ private readonly commandPath;
5
+ private readonly options;
6
+ constructor(command: CommandMetadata, commandPath: string, options: any);
7
+ getCommand(): CommandMetadata;
8
+ getCommandPath(): string;
9
+ getOptions(): any;
10
+ }
11
+ //# sourceMappingURL=commander-execution-context.interface.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commander-execution-context.interface.d.mts","sourceRoot":"","sources":["../../../src/interfaces/commander-execution-context.interface.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAA;AAEvE,qBAAa,yBAAyB;IAElC,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAFP,OAAO,EAAE,eAAe,EACxB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,GAAG;IAG/B,UAAU,IAAI,eAAe;IAI7B,cAAc,IAAI,MAAM;IAIxB,UAAU,IAAI,GAAG;CAGlB"}
@@ -1,3 +1,4 @@
1
1
  export * from './module.interface.mjs';
2
2
  export * from './command-handler.interface.mjs';
3
+ export * from './commander-execution-context.interface.mjs';
3
4
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/interfaces/index.mts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAA;AACtC,cAAc,iCAAiC,CAAA"}
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/interfaces/index.mts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAA;AACtC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,6CAA6C,CAAA"}
@@ -0,0 +1,5 @@
1
+ import { InjectionToken } from '@navios/di';
2
+ import type { CommanderExecutionContext } from '../interfaces/index.mjs';
3
+ export declare const ExecutionContextInjectionToken = "CommanderExecutionContextInjectionToken";
4
+ export declare const ExecutionContext: InjectionToken<CommanderExecutionContext, undefined, false>;
5
+ //# sourceMappingURL=execution-context.token.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-context.token.d.mts","sourceRoot":"","sources":["../../../src/tokens/execution-context.token.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAE3C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAA;AAExE,eAAO,MAAM,8BAA8B,4CACA,CAAA;AAE3C,eAAO,MAAM,gBAAgB,6DAE5B,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from './execution-context.token.mjs';
2
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/tokens/index.mts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAA"}