@arikajs/console 0.0.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ArikaJs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,107 @@
1
+
2
+ ## Arika Console
3
+
4
+ `@arikajs/console` provides the command system for the ArikaJS framework.
5
+
6
+ It allows packages and applications to define, register, and execute CLI commands with arguments, options, and dependency injection — forming the foundation for the `arika` command-line tool.
7
+
8
+ ---
9
+
10
+ ## ✨ Features
11
+
12
+ - **Command registration & discovery**: Effortlessly manage CLI commands
13
+ - **Argument and option parsing**: Structured input handling
14
+ - **Signature-based command definitions**: Intuitive command signatures
15
+ - **Dependency injection for commands**: Resolving commands via the service container
16
+ - **Input/output helpers**: Simplified interaction with terminal
17
+ - **Extensible command lifecycle**: Hooks for pre/post execution
18
+ - **TypeScript-first design**: Typed arguments and options
19
+
20
+ ---
21
+
22
+ ## 📦 Installation
23
+
24
+ ```bash
25
+ npm install @arikajs/console
26
+ # or
27
+ yarn add @arikajs/console
28
+ # or
29
+ pnpm add @arikajs/console
30
+ ```
31
+
32
+ ---
33
+
34
+ ## 🚀 Defining a Command
35
+
36
+ ```ts
37
+ import { Command } from '@arikajs/console';
38
+
39
+ export class QueueWorkCommand extends Command {
40
+ signature = 'queue:work {--once}';
41
+ description = 'Process queued jobs';
42
+
43
+ async handle() {
44
+ // command logic
45
+ this.info('Processing queue...');
46
+
47
+ if (this.option('once')) {
48
+ this.comment('Running in single-work mode');
49
+ }
50
+ }
51
+ }
52
+ ```
53
+
54
+ ### 🧠 Command Signatures
55
+
56
+ `command:name {argument} {--option}`
57
+
58
+ Example:
59
+ `make:controller UserController`
60
+
61
+ ---
62
+
63
+ ## 🖥 Running Commands
64
+
65
+ Commands are executed through the CLI package (`@arikajs/cli`).
66
+ This package focuses only on command behavior, not binaries.
67
+
68
+ ---
69
+
70
+ ## 🔗 Integration
71
+
72
+ - **`@arikajs/queue`** → workers
73
+ - **`@arikajs/cache`** → cache commands
74
+ - **`@arikajs/events`** → event inspection
75
+ - **`@arikajs/logging`** → log tools
76
+
77
+ ---
78
+
79
+ ## 🧠 Architecture (High Level)
80
+
81
+ ```
82
+ console/
83
+ ├── src/
84
+ │ ├── Command.ts
85
+ │ ├── CommandRegistry.ts
86
+ │ ├── Input.ts
87
+ │ ├── Output.ts
88
+ │ ├── Parser.ts
89
+ │ └── index.ts
90
+ ├── tests/
91
+ ├── package.json
92
+ ├── tsconfig.json
93
+ ├── README.md
94
+ └── LICENSE
95
+ ```
96
+
97
+ ---
98
+
99
+ ## 📄 License
100
+
101
+ `@arikajs/console` is open-source software licensed under the **MIT License**.
102
+
103
+ ---
104
+
105
+ ## 🧭 Philosophy
106
+
107
+ > "Powerful tools start with simple commands."
@@ -0,0 +1,26 @@
1
+ import { Input } from './Input';
2
+ import { Output } from './Output';
3
+ export declare abstract class Command {
4
+ abstract signature: string;
5
+ abstract description: string;
6
+ protected input: Input;
7
+ protected output: Output;
8
+ protected registry: any;
9
+ setInput(input: Input): void;
10
+ setOutput(output: Output): void;
11
+ setRegistry(registry: any): void;
12
+ abstract handle(): Promise<any> | any;
13
+ /**
14
+ * Optional initialization hook that runs before handle().
15
+ */
16
+ initialize(): Promise<void> | void;
17
+ protected argument(key: string, defaultValue?: any): any;
18
+ protected option(key: string, defaultValue?: any): any;
19
+ protected info(message: string): void;
20
+ protected error(message: string): void;
21
+ protected warning(message: string): void;
22
+ protected comment(message: string): void;
23
+ protected write(message: string): void;
24
+ protected writeln(message: string): void;
25
+ }
26
+ //# sourceMappingURL=Command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Command.d.ts","sourceRoot":"","sources":["../src/Command.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,8BAAsB,OAAO;IACzB,SAAgB,SAAS,EAAE,MAAM,CAAC;IAClC,SAAgB,WAAW,EAAE,MAAM,CAAC;IAEpC,SAAS,CAAC,KAAK,EAAG,KAAK,CAAC;IACxB,SAAS,CAAC,MAAM,EAAG,MAAM,CAAC;IAC1B,SAAS,CAAC,QAAQ,EAAG,GAAG,CAAC;IAElB,QAAQ,CAAC,KAAK,EAAE,KAAK;IAIrB,SAAS,CAAC,MAAM,EAAE,MAAM;IAIxB,WAAW,CAAC,QAAQ,EAAE,GAAG;aAIhB,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG;IAE5C;;OAEG;IACI,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;IAIzC,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,GAAE,GAAU,GAAG,GAAG;IAI9D,SAAS,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,GAAE,GAAU,GAAG,GAAG;IAI5D,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM;IAI9B,SAAS,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM;IAI/B,SAAS,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM;IAIjC,SAAS,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM;IAIjC,SAAS,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM;IAI/B,SAAS,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM;CAGpC"}
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Command = void 0;
4
+ class Command {
5
+ setInput(input) {
6
+ this.input = input;
7
+ }
8
+ setOutput(output) {
9
+ this.output = output;
10
+ }
11
+ setRegistry(registry) {
12
+ this.registry = registry;
13
+ }
14
+ /**
15
+ * Optional initialization hook that runs before handle().
16
+ */
17
+ initialize() {
18
+ // can be overridden
19
+ }
20
+ argument(key, defaultValue = null) {
21
+ return this.input.argument(key, defaultValue);
22
+ }
23
+ option(key, defaultValue = null) {
24
+ return this.input.option(key, defaultValue);
25
+ }
26
+ info(message) {
27
+ this.output.info(message);
28
+ }
29
+ error(message) {
30
+ this.output.error(message);
31
+ }
32
+ warning(message) {
33
+ this.output.warning(message);
34
+ }
35
+ comment(message) {
36
+ this.output.comment(message);
37
+ }
38
+ write(message) {
39
+ this.output.write(message);
40
+ }
41
+ writeln(message) {
42
+ this.output.writeln(message);
43
+ }
44
+ }
45
+ exports.Command = Command;
46
+ //# sourceMappingURL=Command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Command.js","sourceRoot":"","sources":["../src/Command.ts"],"names":[],"mappings":";;;AAIA,MAAsB,OAAO;IAQlB,QAAQ,CAAC,KAAY;QACxB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;IAEM,SAAS,CAAC,MAAc;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAEM,WAAW,CAAC,QAAa;QAC5B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC7B,CAAC;IAID;;OAEG;IACI,UAAU;QACb,oBAAoB;IACxB,CAAC;IAES,QAAQ,CAAC,GAAW,EAAE,eAAoB,IAAI;QACpD,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;IAClD,CAAC;IAES,MAAM,CAAC,GAAW,EAAE,eAAoB,IAAI;QAClD,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;IAChD,CAAC;IAES,IAAI,CAAC,OAAe;QAC1B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC;IAES,KAAK,CAAC,OAAe;QAC3B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;IAES,OAAO,CAAC,OAAe;QAC7B,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;IAES,OAAO,CAAC,OAAe;QAC7B,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;IAES,KAAK,CAAC,OAAe;QAC3B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;IAES,OAAO,CAAC,OAAe;QAC7B,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;CACJ;AA5DD,0BA4DC"}
@@ -0,0 +1,17 @@
1
+ import { Command } from './Command';
2
+ export declare class CommandRegistry {
3
+ protected commands: Map<string, any>;
4
+ protected resolver: (commandClass: any) => Command;
5
+ constructor(resolver?: (commandClass: any) => Command);
6
+ /**
7
+ * Register a command class.
8
+ */
9
+ register(command: any): void;
10
+ /**
11
+ * Register a command lazily.
12
+ */
13
+ registerLazy(signature: string, description: string, importer: () => Promise<any>): void;
14
+ run(rawArgs: string[]): Promise<any>;
15
+ all(): Map<string, any>;
16
+ }
17
+ //# sourceMappingURL=CommandRegistry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommandRegistry.d.ts","sourceRoot":"","sources":["../src/CommandRegistry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,qBAAa,eAAe;IACxB,SAAS,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAa;IACjD,SAAS,CAAC,QAAQ,EAAE,CAAC,YAAY,EAAE,GAAG,KAAK,OAAO,CAAC;gBAEvC,QAAQ,CAAC,EAAE,CAAC,YAAY,EAAE,GAAG,KAAK,OAAO;IAIrD;;OAEG;IACI,QAAQ,CAAC,OAAO,EAAE,GAAG;IAU5B;;OAEG;IACI,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC;IAU3E,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE;IAoC3B,GAAG;CAGb"}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CommandRegistry = void 0;
4
+ const Parser_1 = require("./Parser");
5
+ const Input_1 = require("./Input");
6
+ const Output_1 = require("./Output");
7
+ class CommandRegistry {
8
+ constructor(resolver) {
9
+ this.commands = new Map();
10
+ this.resolver = resolver || ((cls) => new cls());
11
+ }
12
+ /**
13
+ * Register a command class.
14
+ */
15
+ register(command) {
16
+ const instance = this.resolver(command);
17
+ const { name } = Parser_1.Parser.parseSignature(instance.signature);
18
+ this.commands.set(name, {
19
+ class: command,
20
+ signature: instance.signature,
21
+ description: instance.description
22
+ });
23
+ }
24
+ /**
25
+ * Register a command lazily.
26
+ */
27
+ registerLazy(signature, description, importer) {
28
+ const { name } = Parser_1.Parser.parseSignature(signature);
29
+ this.commands.set(name, {
30
+ isLazy: true,
31
+ signature,
32
+ description,
33
+ importer
34
+ });
35
+ }
36
+ async run(rawArgs) {
37
+ const commandName = rawArgs[0];
38
+ const commandData = this.commands.get(commandName);
39
+ if (!commandData) {
40
+ throw new Error(`Command "${commandName}" not found.`);
41
+ }
42
+ let commandClass = commandData.class;
43
+ if (commandData.isLazy) {
44
+ const module = await commandData.importer();
45
+ // Try to find the class in the module (default export or first exported class)
46
+ commandClass = module.default || Object.values(module).find(v => typeof v === 'function');
47
+ }
48
+ if (!commandClass) {
49
+ throw new Error(`Could not resolve command class for "${commandName}".`);
50
+ }
51
+ const command = this.resolver(commandClass);
52
+ const signature = Parser_1.Parser.parseSignature(command.signature);
53
+ const { arguments: args, options } = Parser_1.Parser.parseArguments(rawArgs.slice(1), signature);
54
+ const input = new Input_1.Input(args, options);
55
+ const output = new Output_1.Output();
56
+ command.setInput(input);
57
+ command.setOutput(output);
58
+ command.setRegistry(this);
59
+ await command.initialize();
60
+ return await command.handle();
61
+ }
62
+ all() {
63
+ return this.commands;
64
+ }
65
+ }
66
+ exports.CommandRegistry = CommandRegistry;
67
+ //# sourceMappingURL=CommandRegistry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommandRegistry.js","sourceRoot":"","sources":["../src/CommandRegistry.ts"],"names":[],"mappings":";;;AAEA,qCAAkC;AAClC,mCAAgC;AAChC,qCAAkC;AAElC,MAAa,eAAe;IAIxB,YAAY,QAAyC;QAH3C,aAAQ,GAAqB,IAAI,GAAG,EAAE,CAAC;QAI7C,IAAI,CAAC,QAAQ,GAAG,QAAQ,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC;IACrD,CAAC;IAED;;OAEG;IACI,QAAQ,CAAC,OAAY;QACxB,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,O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ChB,MAAM,IAAI,KAAK,CAAC,wCAAwC,WAAW,IAAI,CAAC,CAAC;QAC7E,CAAC;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;QAC5C,MAAM,SAAS,GAAG,eAAM,CAAC,cAAc,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAC3D,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,eAAM,CAAC,cAAc,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;QAExF,MAAM,KAAK,GAAG,IAAI,aAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACvC,MAAM,MAAM,GAAG,IAAI,eAAM,EAAE,CAAC;QAE5B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACxB,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAC1B,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QAE1B,MAAM,OAAO,CAAC,UAAU,EAAE,CAAC;QAE3B,OAAO,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC;IAClC,CAAC;IAEM,GAAG;QACN,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;CACJ;AAzED,0CAyEC"}
@@ -0,0 +1,10 @@
1
+ export declare class Input {
2
+ protected arguments_list: Map<string, any>;
3
+ protected options_list: Map<string, any>;
4
+ constructor(arguments_list?: Map<string, any>, options_list?: Map<string, any>);
5
+ argument(key: string, defaultValue?: any): any;
6
+ option(key: string, defaultValue?: any): any;
7
+ setArguments(args: Map<string, any>): void;
8
+ setOptions(options: Map<string, any>): void;
9
+ }
10
+ //# sourceMappingURL=Input.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../src/Input.ts"],"names":[],"mappings":"AACA,qBAAa,KAAK;IAEV,SAAS,CAAC,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC;IAC1C,SAAS,CAAC,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC;gBAD9B,cAAc,GAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAa,EAC5C,YAAY,GAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAa;IAGjD,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,GAAE,GAAU,GAAG,GAAG;IAIpD,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,GAAE,GAAU,GAAG,GAAG;IAIlD,YAAY,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC;IAInC,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC;CAG9C"}
package/dist/Input.js ADDED
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Input = void 0;
4
+ class Input {
5
+ constructor(arguments_list = new Map(), options_list = new Map()) {
6
+ this.arguments_list = arguments_list;
7
+ this.options_list = options_list;
8
+ }
9
+ argument(key, defaultValue = null) {
10
+ return this.arguments_list.has(key) ? this.arguments_list.get(key) : defaultValue;
11
+ }
12
+ option(key, defaultValue = null) {
13
+ return this.options_list.has(key) ? this.options_list.get(key) : defaultValue;
14
+ }
15
+ setArguments(args) {
16
+ this.arguments_list = args;
17
+ }
18
+ setOptions(options) {
19
+ this.options_list = options;
20
+ }
21
+ }
22
+ exports.Input = Input;
23
+ //# sourceMappingURL=Input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Input.js","sourceRoot":"","sources":["../src/Input.ts"],"names":[],"mappings":";;;AACA,MAAa,KAAK;IACd,YACc,iBAAmC,IAAI,GAAG,EAAE,EAC5C,eAAiC,IAAI,GAAG,EAAE;QAD1C,mBAAc,GAAd,cAAc,CAA8B;QAC5C,iBAAY,GAAZ,YAAY,CAA8B;IACpD,CAAC;IAEE,QAAQ,CAAC,GAAW,EAAE,eAAoB,IAAI;QACjD,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC;IACtF,CAAC;IAEM,MAAM,CAAC,GAAW,EAAE,eAAoB,IAAI;QAC/C,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC;IAClF,CAAC;IAEM,YAAY,CAAC,IAAsB;QACtC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;IAC/B,CAAC;IAEM,UAAU,CAAC,OAAyB;QACvC,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC;IAChC,CAAC;CACJ;AArBD,sBAqBC"}
@@ -0,0 +1,9 @@
1
+ export declare class Output {
2
+ write(message: string): void;
3
+ writeln(message: string): void;
4
+ info(message: string): void;
5
+ error(message: string): void;
6
+ warning(message: string): void;
7
+ comment(message: string): void;
8
+ }
9
+ //# sourceMappingURL=Output.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Output.d.ts","sourceRoot":"","sources":["../src/Output.ts"],"names":[],"mappings":"AACA,qBAAa,MAAM;IACR,KAAK,CAAC,OAAO,EAAE,MAAM;IAIrB,OAAO,CAAC,OAAO,EAAE,MAAM;IAIvB,IAAI,CAAC,OAAO,EAAE,MAAM;IAIpB,KAAK,CAAC,OAAO,EAAE,MAAM;IAIrB,OAAO,CAAC,OAAO,EAAE,MAAM;IAIvB,OAAO,CAAC,OAAO,EAAE,MAAM;CAGjC"}
package/dist/Output.js ADDED
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Output = void 0;
4
+ class Output {
5
+ write(message) {
6
+ process.stdout.write(message);
7
+ }
8
+ writeln(message) {
9
+ process.stdout.write(message + '\n');
10
+ }
11
+ info(message) {
12
+ this.writeln(`\x1b[32m${message}\x1b[0m`); // Green
13
+ }
14
+ error(message) {
15
+ process.stderr.write(`\x1b[31m${message}\x1b[0m\n`); // Red
16
+ }
17
+ warning(message) {
18
+ this.writeln(`\x1b[33m${message}\x1b[0m`); // Yellow
19
+ }
20
+ comment(message) {
21
+ this.writeln(`\x1b[34m${message}\x1b[0m`); // Blue
22
+ }
23
+ }
24
+ exports.Output = Output;
25
+ //# sourceMappingURL=Output.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Output.js","sourceRoot":"","sources":["../src/Output.ts"],"names":[],"mappings":";;;AACA,MAAa,MAAM;IACR,KAAK,CAAC,OAAe;QACxB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAClC,CAAC;IAEM,OAAO,CAAC,OAAe;QAC1B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;IACzC,CAAC;IAEM,IAAI,CAAC,OAAe;QACvB,IAAI,CAAC,OAAO,CAAC,WAAW,OAAO,SAAS,CAAC,CAAC,CAAC,QAAQ;IACvD,CAAC;IAEM,KAAK,CAAC,OAAe;QACxB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,OAAO,WAAW,CAAC,CAAC,CAAC,MAAM;IAC/D,CAAC;IAEM,OAAO,CAAC,OAAe;QAC1B,IAAI,CAAC,OAAO,CAAC,WAAW,OAAO,SAAS,CAAC,CAAC,CAAC,SAAS;IACxD,CAAC;IAEM,OAAO,CAAC,OAAe;QAC1B,IAAI,CAAC,OAAO,CAAC,WAAW,OAAO,SAAS,CAAC,CAAC,CAAC,OAAO;IACtD,CAAC;CACJ;AAxBD,wBAwBC"}
@@ -0,0 +1,19 @@
1
+ export interface ParsedSignature {
2
+ name: string;
3
+ arguments: {
4
+ name: string;
5
+ required: boolean;
6
+ }[];
7
+ options: {
8
+ name: string;
9
+ hasValue: boolean;
10
+ }[];
11
+ }
12
+ export declare class Parser {
13
+ static parseSignature(signature: string): ParsedSignature;
14
+ static parseArguments(rawArgs: string[], signature: ParsedSignature): {
15
+ arguments: Map<string, any>;
16
+ options: Map<string, any>;
17
+ };
18
+ }
19
+ //# sourceMappingURL=Parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Parser.d.ts","sourceRoot":"","sources":["../src/Parser.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,eAAe;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,EAAE,CAAC;IACjD,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,EAAE,CAAC;CAClD;AAED,qBAAa,MAAM;WACD,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,eAAe;WA4BlD,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,eAAe;;;;CAuB7E"}
package/dist/Parser.js ADDED
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Parser = void 0;
4
+ class Parser {
5
+ static parseSignature(signature) {
6
+ const parts = signature.split(/\s+/);
7
+ const name = parts[0];
8
+ const args = [];
9
+ const options = [];
10
+ for (let i = 1; i < parts.length; i++) {
11
+ const part = parts[i];
12
+ // Match {argument} or {argument?}
13
+ const argMatch = part.match(/^\{([^}]+)\}$/);
14
+ if (argMatch) {
15
+ const argName = argMatch[1];
16
+ if (argName.startsWith('--')) {
17
+ const optName = argName.substring(2);
18
+ options.push({ name: optName, hasValue: optName.includes('=') });
19
+ }
20
+ else {
21
+ args.push({
22
+ name: argName.endsWith('?') ? argName.slice(0, -1) : argName,
23
+ required: !argName.endsWith('?')
24
+ });
25
+ }
26
+ }
27
+ }
28
+ return { name, arguments: args, options };
29
+ }
30
+ static parseArguments(rawArgs, signature) {
31
+ const argsMap = new Map();
32
+ const optionsMap = new Map();
33
+ let argIndex = 0;
34
+ for (let i = 0; i < rawArgs.length; i++) {
35
+ const raw = rawArgs[i];
36
+ if (raw.startsWith('--')) {
37
+ const [optName, optValue] = raw.substring(2).split('=');
38
+ if (optValue !== undefined) {
39
+ optionsMap.set(optName, optValue);
40
+ }
41
+ else {
42
+ optionsMap.set(optName, true);
43
+ }
44
+ }
45
+ else if (argIndex < signature.arguments.length) {
46
+ argsMap.set(signature.arguments[argIndex].name, raw);
47
+ argIndex++;
48
+ }
49
+ }
50
+ return { arguments: argsMap, options: optionsMap };
51
+ }
52
+ }
53
+ exports.Parser = Parser;
54
+ //# sourceMappingURL=Parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Parser.js","sourceRoot":"","sources":["../src/Parser.ts"],"names":[],"mappings":";;;AAOA,MAAa,MAAM;IACR,MAAM,CAAC,cAAc,CAAC,SAAiB;QAC1C,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACrC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACtB,MAAM,IAAI,GAA0C,EAAE,CAAC;QACvD,MAAM,OAAO,GAA0C,EAAE,CAAC;QAE1D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACpC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YAEtB,kCAAkC;YAClC,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;YAC7C,IAAI,QAAQ,EAAE,CAAC;gBACX,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;gBAC5B,IAAI,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAA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,CAAC,CAAC;gBACtC,CAAC;qBAAM,CAAC;oBACJ,UAAU,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;gBAClC,CAAC;YACL,CAAC;iBAAM,IAAI,QAAQ,GAAG,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;gBAC/C,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;gBACrD,QAAQ,EAAE,CAAC;YACf,CAAC;QACL,CAAC;QAED,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;IACvD,CAAC;CACJ;AApDD,wBAoDC"}
@@ -0,0 +1,6 @@
1
+ export { Command } from './Command';
2
+ export { CommandRegistry } from './CommandRegistry';
3
+ export { Input } from './Input';
4
+ export { Output } from './Output';
5
+ export { Parser } from './Parser';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Parser = exports.Output = exports.Input = exports.CommandRegistry = exports.Command = void 0;
4
+ var Command_1 = require("./Command");
5
+ Object.defineProperty(exports, "Command", { enumerable: true, get: function () { return Command_1.Command; } });
6
+ var CommandRegistry_1 = require("./CommandRegistry");
7
+ Object.defineProperty(exports, "CommandRegistry", { enumerable: true, get: function () { return CommandRegistry_1.CommandRegistry; } });
8
+ var Input_1 = require("./Input");
9
+ Object.defineProperty(exports, "Input", { enumerable: true, get: function () { return Input_1.Input; } });
10
+ var Output_1 = require("./Output");
11
+ Object.defineProperty(exports, "Output", { enumerable: true, get: function () { return Output_1.Output; } });
12
+ var Parser_1 = require("./Parser");
13
+ Object.defineProperty(exports, "Parser", { enumerable: true, get: function () { return Parser_1.Parser; } });
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AACA,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAChB,qDAAoD;AAA3C,kHAAA,eAAe,OAAA;AACxB,iCAAgC;AAAvB,8FAAA,KAAK,OAAA;AACd,mCAAkC;AAAzB,gGAAA,MAAM,OAAA;AACf,mCAAkC;AAAzB,gGAAA,MAAM,OAAA"}
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@arikajs/console",
3
+ "version": "0.0.1",
4
+ "description": "The command system for the ArikaJS framework.",
5
+ "license": "MIT",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "scripts": {
9
+ "build": "tsc -p tsconfig.json",
10
+ "build:tests": "tsc -p tsconfig.test.json",
11
+ "clean": "rm -rf dist",
12
+ "prepare": "echo skip",
13
+ "test": "npm run build && npm run build:tests && node scripts/fix-test-imports.js && node --test 'dist/tests/**/*.test.js'",
14
+ "test:watch": "npm run build && npm run build:tests && node --test --watch 'dist/tests/**/*.test.js'"
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "keywords": [
20
+ "arika",
21
+ "arika-js",
22
+ "console",
23
+ "command",
24
+ "cli"
25
+ ],
26
+ "engines": {
27
+ "node": ">=20.0.0"
28
+ },
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "git+https://github.com/arikajs/console.git"
32
+ },
33
+ "bugs": {
34
+ "url": "https://github.com/arikajs/console/issues"
35
+ },
36
+ "homepage": "https://github.com/arikajs/console#readme",
37
+ "dependencies": {},
38
+ "devDependencies": {
39
+ "@types/node": "^20.11.24",
40
+ "typescript": "^5.3.3"
41
+ },
42
+ "author": "Prakash Tank"
43
+ }