@qodalis/cli-core 0.0.15 → 2.0.0-beta.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/README.md +399 -31
- package/package.json +16 -23
- package/public-api.d.mts +2322 -0
- package/public-api.d.ts +2322 -8
- package/public-api.js +3597 -0
- package/public-api.js.map +1 -0
- package/public-api.mjs +3545 -0
- package/public-api.mjs.map +1 -0
- package/esm2022/lib/constants/index.mjs +0 -8
- package/esm2022/lib/interfaces/command-hooks.mjs +0 -2
- package/esm2022/lib/interfaces/command-processor.mjs +0 -2
- package/esm2022/lib/interfaces/execution-context.mjs +0 -2
- package/esm2022/lib/interfaces/index.mjs +0 -6
- package/esm2022/lib/interfaces/progress-bars.mjs +0 -2
- package/esm2022/lib/interfaces/users.mjs +0 -2
- package/esm2022/lib/models/index.mjs +0 -175
- package/esm2022/lib/models/services.mjs +0 -2
- package/esm2022/lib/models/users.mjs +0 -2
- package/esm2022/lib/modules/index.mjs +0 -30
- package/esm2022/lib/themes/index.mjs +0 -221
- package/esm2022/lib/types/CancellablePromise.mjs +0 -28
- package/esm2022/lib/types/index.mjs +0 -2
- package/esm2022/lib/utils/delay.mjs +0 -4
- package/esm2022/lib/utils/index.mjs +0 -80
- package/esm2022/lib/utils/object-describer.mjs +0 -134
- package/esm2022/lib/utils/terminal-utils.mjs +0 -16
- package/esm2022/lib/version.mjs +0 -3
- package/esm2022/public-api.mjs +0 -12
- package/esm2022/qodalis-cli-core.mjs +0 -5
- package/fesm2022/qodalis-cli-core.mjs +0 -697
- package/fesm2022/qodalis-cli-core.mjs.map +0 -1
- package/index.d.ts +0 -5
- package/lib/constants/index.d.ts +0 -5
- package/lib/interfaces/command-hooks.d.ts +0 -5
- package/lib/interfaces/command-processor.d.ts +0 -151
- package/lib/interfaces/execution-context.d.ts +0 -109
- package/lib/interfaces/index.d.ts +0 -349
- package/lib/interfaces/progress-bars.d.ts +0 -72
- package/lib/interfaces/users.d.ts +0 -42
- package/lib/models/index.d.ts +0 -293
- package/lib/models/services.d.ts +0 -20
- package/lib/models/users.d.ts +0 -30
- package/lib/modules/index.d.ts +0 -6
- package/lib/themes/index.d.ts +0 -16
- package/lib/types/CancellablePromise.d.ts +0 -8
- package/lib/types/index.d.ts +0 -1
- package/lib/utils/delay.d.ts +0 -1
- package/lib/utils/index.d.ts +0 -24
- package/lib/utils/object-describer.d.ts +0 -12
- package/lib/utils/terminal-utils.d.ts +0 -7
- package/lib/version.d.ts +0 -1
package/README.md
CHANGED
|
@@ -1,34 +1,45 @@
|
|
|
1
|
-
<h1 align="center">Qodalis
|
|
1
|
+
<h1 align="center">Qodalis Web CLI</h1>
|
|
2
2
|
|
|
3
|
-
<p align="center">A web-based terminal for Angular
|
|
3
|
+
<p align="center">A web-based terminal for Angular, React, and Vue — extensible, themeable, and packed with built-in developer tools.</p>
|
|
4
4
|
|
|
5
5
|
<div align="center">
|
|
6
6
|
|
|
7
|
-
[](https://www.npmjs.com/package/@qodalis/cli)
|
|
8
|
+
[](https://www.npmjs.com/package/@qodalis/angular-cli)
|
|
9
|
+
[](https://www.npmjs.com/package/@qodalis/react-cli)
|
|
10
|
+
[](https://www.npmjs.com/package/@qodalis/vue-cli)
|
|
11
|
+
[](https://github.com/qodalis-solutions/web-cli/actions)
|
|
9
12
|
[](https://opensource.org/licenses/MIT)
|
|
10
13
|
|
|
11
14
|
</div>
|
|
12
15
|
|
|
13
16
|
<p align="center">
|
|
14
|
-
<a href="https://cli
|
|
15
|
-
<a href="https://
|
|
16
|
-
<a href="https://www.npmjs.com/package/@qodalis/
|
|
17
|
+
<a href="https://cli.qodalis.com/">Live Demo</a> ·
|
|
18
|
+
<a href="https://cli.qodalis.com/docs/">Documentation</a> ·
|
|
19
|
+
<a href="https://www.npmjs.com/package/@qodalis/cli">npm</a>
|
|
17
20
|
</p>
|
|
18
21
|
|
|
19
22
|
---
|
|
20
23
|
|
|
21
24
|

|
|
22
25
|
|
|
23
|
-
##
|
|
26
|
+
## Packages
|
|
24
27
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
| Package | Description |
|
|
29
|
+
|---------|-------------|
|
|
30
|
+
| [`@qodalis/cli-core`](https://www.npmjs.com/package/@qodalis/cli-core) | Shared interfaces, models, and types |
|
|
31
|
+
| [`@qodalis/cli`](https://www.npmjs.com/package/@qodalis/cli) | Framework-agnostic terminal engine (50+ built-in commands) |
|
|
32
|
+
| [`@qodalis/angular-cli`](https://www.npmjs.com/package/@qodalis/angular-cli) | Angular wrapper |
|
|
33
|
+
| [`@qodalis/react-cli`](https://www.npmjs.com/package/@qodalis/react-cli) | React wrapper |
|
|
34
|
+
| [`@qodalis/vue-cli`](https://www.npmjs.com/package/@qodalis/vue-cli) | Vue 3 wrapper |
|
|
28
35
|
|
|
29
36
|
## Quick Start
|
|
30
37
|
|
|
31
|
-
|
|
38
|
+
### Angular
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npm install @qodalis/angular-cli
|
|
42
|
+
```
|
|
32
43
|
|
|
33
44
|
```typescript
|
|
34
45
|
import { CliModule } from '@qodalis/angular-cli';
|
|
@@ -39,7 +50,7 @@ import { CliModule } from '@qodalis/angular-cli';
|
|
|
39
50
|
export class AppModule {}
|
|
40
51
|
```
|
|
41
52
|
|
|
42
|
-
|
|
53
|
+
Add styles to `angular.json`:
|
|
43
54
|
|
|
44
55
|
```json
|
|
45
56
|
{
|
|
@@ -49,20 +60,50 @@ export class AppModule {}
|
|
|
49
60
|
}
|
|
50
61
|
```
|
|
51
62
|
|
|
52
|
-
**3. Add the terminal to your template:**
|
|
53
|
-
|
|
54
63
|
```html
|
|
55
64
|
<!-- Full terminal -->
|
|
56
65
|
<cli [options]="cliOptions" />
|
|
57
66
|
|
|
58
|
-
<!-- Collapsible panel
|
|
67
|
+
<!-- Collapsible panel -->
|
|
59
68
|
<cli-panel />
|
|
60
69
|
```
|
|
61
70
|
|
|
62
|
-
|
|
71
|
+
### React
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
npm install @qodalis/react-cli
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
```tsx
|
|
78
|
+
import { Cli } from '@qodalis/react-cli';
|
|
79
|
+
|
|
80
|
+
function App() {
|
|
81
|
+
return <Cli style={{ width: '100vw', height: '100vh' }} />;
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Vue
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
npm install @qodalis/vue-cli
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
```vue
|
|
92
|
+
<script setup lang="ts">
|
|
93
|
+
import { Cli } from '@qodalis/vue-cli';
|
|
94
|
+
</script>
|
|
95
|
+
|
|
96
|
+
<template>
|
|
97
|
+
<Cli :style="{ width: '100vw', height: '100vh' }" />
|
|
98
|
+
</template>
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Configuration (all frameworks)
|
|
102
|
+
|
|
103
|
+
Pass options to customize the terminal:
|
|
63
104
|
|
|
64
105
|
```typescript
|
|
65
|
-
|
|
106
|
+
const options = {
|
|
66
107
|
welcomeMessage: {
|
|
67
108
|
message: '-- your custom welcome message --',
|
|
68
109
|
show: 'daily', // 'never', 'once', 'daily', 'always'
|
|
@@ -83,7 +124,7 @@ cliOptions = {
|
|
|
83
124
|
| `version` | `ver` | Display CLI version and documentation link |
|
|
84
125
|
| `hotkeys` | `shortcuts`, `keys` | Show keyboard shortcuts |
|
|
85
126
|
| `history` | `hist` | Browse and clear command history |
|
|
86
|
-
| `theme` | `themes` | Apply, customize, and save terminal themes |
|
|
127
|
+
| `theme` | `themes` | Apply, customize, and save terminal themes (interactive selection with live preview) |
|
|
87
128
|
| `feedback` | `support` | Report bugs or request features on GitHub |
|
|
88
129
|
| `pkg` | `packages` | Install, update, remove, and browse packages |
|
|
89
130
|
|
|
@@ -145,6 +186,8 @@ pkg update # Update all packages
|
|
|
145
186
|
pkg update guid@1.0.2 # Pin a specific version
|
|
146
187
|
pkg check # Check for updates
|
|
147
188
|
pkg versions guid # Show all published versions
|
|
189
|
+
pkg source set # Interactively select a package source (CDN)
|
|
190
|
+
pkg source set unpkg # Set package source directly
|
|
148
191
|
```
|
|
149
192
|
|
|
150
193
|
### Available Packages
|
|
@@ -170,9 +213,318 @@ pkg add lodash
|
|
|
170
213
|
eval _.map([1, 2, 3], n => n * 2)
|
|
171
214
|
```
|
|
172
215
|
|
|
173
|
-
##
|
|
216
|
+
## Creating a CLI Plugin
|
|
217
|
+
|
|
218
|
+
### Quick Start
|
|
219
|
+
|
|
220
|
+
Scaffold a complete plugin project with a single command:
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
npx @qodalis/create-cli-plugin
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
The interactive prompts will ask for:
|
|
227
|
+
|
|
228
|
+
| Prompt | Description | Example |
|
|
229
|
+
|--------|-------------|---------|
|
|
230
|
+
| **Plugin name** | Lowercase, no spaces, no `cli-` prefix (added automatically) | `weather` |
|
|
231
|
+
| **Description** | Short description of the plugin | `Weather forecasts` |
|
|
232
|
+
| **Processor class name** | PascalCase name for the command processor class | `Weather` |
|
|
233
|
+
|
|
234
|
+
You can also skip the prompts by passing arguments directly:
|
|
235
|
+
|
|
236
|
+
```bash
|
|
237
|
+
npx @qodalis/create-cli-plugin --name weather --description "Weather forecasts" --processor-name Weather
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
Or install globally:
|
|
241
|
+
|
|
242
|
+
```bash
|
|
243
|
+
npm install -g @qodalis/create-cli-plugin
|
|
244
|
+
create-cli-plugin
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
### Standalone vs Monorepo Mode
|
|
248
|
+
|
|
249
|
+
The tool auto-detects whether you're inside the `web-cli` monorepo:
|
|
250
|
+
|
|
251
|
+
| Mode | Detection | Output directory | Package manager |
|
|
252
|
+
|------|-----------|-----------------|-----------------|
|
|
253
|
+
| **Standalone** | Any directory outside web-cli | `./qodalis-cli-<name>/` | npm or pnpm (auto-detected) |
|
|
254
|
+
| **Monorepo** | Inside web-cli workspace | `packages/plugins/<name>/` | pnpm (workspace) |
|
|
255
|
+
|
|
256
|
+
In monorepo mode, the tool also:
|
|
257
|
+
- Creates `project.json` (Nx build + test targets)
|
|
258
|
+
- Creates `tsconfig.spec.json` (Karma/Jasmine test config)
|
|
259
|
+
- Updates `tsconfig.base.json` with the path alias `@qodalis/cli-<name>` → `dist/<name>`
|
|
260
|
+
|
|
261
|
+
### Generated Project Structure
|
|
262
|
+
|
|
263
|
+
```
|
|
264
|
+
qodalis-cli-weather/ # or packages/plugins/weather/ in monorepo
|
|
265
|
+
package.json # npm package with CJS/ESM/UMD exports
|
|
266
|
+
tsup.config.ts # Build config (library + IIFE bundles)
|
|
267
|
+
tsconfig.json # TypeScript config
|
|
268
|
+
README.md # Auto-generated README
|
|
269
|
+
src/
|
|
270
|
+
public-api.ts # Public exports + ICliModule declaration
|
|
271
|
+
cli-entrypoint.ts # IIFE entrypoint for browser runtime loading
|
|
272
|
+
lib/
|
|
273
|
+
version.ts # LIBRARY_VERSION + API_VERSION constants
|
|
274
|
+
index.ts # Barrel re-exports
|
|
275
|
+
processors/
|
|
276
|
+
cli-weather-command-processor.ts # Command processor (your main logic goes here)
|
|
277
|
+
tests/
|
|
278
|
+
index.spec.ts # Jasmine test scaffold
|
|
279
|
+
```
|
|
174
280
|
|
|
175
|
-
|
|
281
|
+
### Step-by-Step Workflow
|
|
282
|
+
|
|
283
|
+
#### 1. Scaffold the plugin
|
|
284
|
+
|
|
285
|
+
```bash
|
|
286
|
+
npx @qodalis/create-cli-plugin --name weather
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
#### 2. Implement your command processor
|
|
290
|
+
|
|
291
|
+
Edit `src/lib/processors/cli-weather-command-processor.ts`:
|
|
292
|
+
|
|
293
|
+
```typescript
|
|
294
|
+
import {
|
|
295
|
+
CliProcessCommand,
|
|
296
|
+
DefaultLibraryAuthor,
|
|
297
|
+
ICliCommandProcessor,
|
|
298
|
+
ICliExecutionContext,
|
|
299
|
+
} from '@qodalis/cli-core';
|
|
300
|
+
import { LIBRARY_VERSION } from '../version';
|
|
301
|
+
|
|
302
|
+
export class CliWeatherCommandProcessor implements ICliCommandProcessor {
|
|
303
|
+
command = 'weather';
|
|
304
|
+
description = 'Weather forecasts';
|
|
305
|
+
author = DefaultLibraryAuthor;
|
|
306
|
+
version = LIBRARY_VERSION;
|
|
307
|
+
|
|
308
|
+
// Sub-commands
|
|
309
|
+
processors?: ICliCommandProcessor[] = [
|
|
310
|
+
{
|
|
311
|
+
command: 'forecast',
|
|
312
|
+
description: 'Get weather forecast for a city',
|
|
313
|
+
parameters: [
|
|
314
|
+
{
|
|
315
|
+
name: 'city',
|
|
316
|
+
aliases: ['c'],
|
|
317
|
+
description: 'City name',
|
|
318
|
+
required: true,
|
|
319
|
+
type: 'string',
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
name: 'days',
|
|
323
|
+
aliases: ['d'],
|
|
324
|
+
description: 'Number of days',
|
|
325
|
+
required: false,
|
|
326
|
+
type: 'number',
|
|
327
|
+
defaultValue: '3',
|
|
328
|
+
},
|
|
329
|
+
],
|
|
330
|
+
processCommand: async (command, context) => {
|
|
331
|
+
const city = command.args['city'];
|
|
332
|
+
const days = parseInt(command.args['days'] ?? '3');
|
|
333
|
+
context.writer.writeln(`Forecast for ${city} (${days} days):`);
|
|
334
|
+
context.writer.writeSuccess('Sunny, 25°C');
|
|
335
|
+
},
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
command: 'current',
|
|
339
|
+
description: 'Get current weather',
|
|
340
|
+
acceptsRawInput: true, // command.value = text after 'current'
|
|
341
|
+
valueRequired: true, // error if no value provided
|
|
342
|
+
processCommand: async (command, context) => {
|
|
343
|
+
context.writer.writeln(`Current weather in ${command.value}: Sunny, 25°C`);
|
|
344
|
+
},
|
|
345
|
+
},
|
|
346
|
+
];
|
|
347
|
+
|
|
348
|
+
// Default handler (runs when user types just 'weather')
|
|
349
|
+
async processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void> {
|
|
350
|
+
context.executor.showHelp(command, context);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
#### 3. Build the plugin
|
|
356
|
+
|
|
357
|
+
**Standalone:**
|
|
358
|
+
|
|
359
|
+
```bash
|
|
360
|
+
cd qodalis-cli-weather
|
|
361
|
+
npm run build # or: npx tsup
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
**Monorepo:**
|
|
365
|
+
|
|
366
|
+
```bash
|
|
367
|
+
pnpm nx build weather
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
Build output goes to `dist/weather/` with three bundles:
|
|
371
|
+
- `public-api.js` (CJS) + `public-api.mjs` (ESM) + `public-api.d.ts` (types)
|
|
372
|
+
- `umd/index.js` (IIFE — self-contained browser bundle for runtime `pkg add`)
|
|
373
|
+
|
|
374
|
+
#### 4. Test the plugin
|
|
375
|
+
|
|
376
|
+
**Standalone:** Add your preferred test runner.
|
|
377
|
+
|
|
378
|
+
**Monorepo:**
|
|
379
|
+
|
|
380
|
+
```bash
|
|
381
|
+
pnpm nx test weather
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
#### 5. Publish to npm
|
|
385
|
+
|
|
386
|
+
```bash
|
|
387
|
+
cd dist/weather # or: cd qodalis-cli-weather/dist
|
|
388
|
+
npm publish --access public
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
Users can then install your plugin at runtime in any Qodalis CLI terminal:
|
|
392
|
+
|
|
393
|
+
```bash
|
|
394
|
+
pkg add @qodalis/cli-weather
|
|
395
|
+
weather forecast --city "New York"
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
### The ICliModule Export
|
|
399
|
+
|
|
400
|
+
Every plugin exports an `ICliModule` object in `public-api.ts`. This is how frameworks register your plugin:
|
|
401
|
+
|
|
402
|
+
```typescript
|
|
403
|
+
import { ICliModule } from '@qodalis/cli-core';
|
|
404
|
+
import { CliWeatherCommandProcessor } from './lib/processors/cli-weather-command-processor';
|
|
405
|
+
import { API_VERSION } from './lib/version';
|
|
406
|
+
|
|
407
|
+
export const weatherModule: ICliModule = {
|
|
408
|
+
apiVersion: API_VERSION, // must be >= 2
|
|
409
|
+
name: '@qodalis/cli-weather',
|
|
410
|
+
processors: [new CliWeatherCommandProcessor()],
|
|
411
|
+
};
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
`ICliModule` also supports optional lifecycle hooks and configuration:
|
|
415
|
+
|
|
416
|
+
```typescript
|
|
417
|
+
export const weatherModule: ICliModule = {
|
|
418
|
+
apiVersion: 2,
|
|
419
|
+
name: '@qodalis/cli-weather',
|
|
420
|
+
processors: [new CliWeatherCommandProcessor()],
|
|
421
|
+
dependencies: ['@qodalis/cli-curl'], // boot other modules first
|
|
422
|
+
priority: 0, // boot order (lower = first)
|
|
423
|
+
configure(config) { /* ... */ return this; },
|
|
424
|
+
onInit(context) { /* before processors initialize */ },
|
|
425
|
+
onAfterBoot(context) { /* after all modules boot */ },
|
|
426
|
+
onDestroy(context) { /* teardown */ },
|
|
427
|
+
};
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
### The IIFE Entrypoint
|
|
431
|
+
|
|
432
|
+
`src/cli-entrypoint.ts` enables runtime loading via `pkg add`. It calls `bootCliModule()` which registers the module with the global `window.__cliModuleRegistry`:
|
|
433
|
+
|
|
434
|
+
```typescript
|
|
435
|
+
import { bootCliModule, ICliModule } from '@qodalis/cli-core';
|
|
436
|
+
import { CliWeatherCommandProcessor } from './lib/processors/cli-weather-command-processor';
|
|
437
|
+
import { API_VERSION } from './lib/version';
|
|
438
|
+
|
|
439
|
+
const module: ICliModule = {
|
|
440
|
+
apiVersion: API_VERSION,
|
|
441
|
+
name: '@qodalis/cli-weather',
|
|
442
|
+
processors: [new CliWeatherCommandProcessor()],
|
|
443
|
+
};
|
|
444
|
+
|
|
445
|
+
bootCliModule(module);
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
### Execution Context API
|
|
449
|
+
|
|
450
|
+
The `ICliExecutionContext` passed to `processCommand` provides:
|
|
451
|
+
|
|
452
|
+
| Property | Description |
|
|
453
|
+
|----------|-------------|
|
|
454
|
+
| `context.writer` | Terminal output — `writeln()`, `writeInfo()`, `writeSuccess()`, `writeError()`, `wrapInColor()` |
|
|
455
|
+
| `context.reader` | User input — `readLine()`, `readPassword()`, `readConfirm()`, `readSelect()`, `readMultiSelect()`, `readNumber()` |
|
|
456
|
+
| `context.executor` | Command execution — `showHelp(command, context)` |
|
|
457
|
+
| `context.clipboard` | Clipboard — `write()`, `read()` |
|
|
458
|
+
| `context.state` | Persistent key-value store |
|
|
459
|
+
| `context.progressBar` | Progress bar widget |
|
|
460
|
+
| `context.spinner` | Spinner widget |
|
|
461
|
+
| `context.terminal` | Raw xterm.js `Terminal` instance |
|
|
462
|
+
| `context.onAbort` | `Subject<void>` for Ctrl+C cancellation |
|
|
463
|
+
| `context.enterFullScreenMode()` | Switch to full-screen TUI mode |
|
|
464
|
+
| `context.createInterval()` / `context.createTimeout()` | Managed timers (auto-cleaned on abort) |
|
|
465
|
+
|
|
466
|
+
### Registering Plugins in Your App
|
|
467
|
+
|
|
468
|
+
#### Angular (via providers)
|
|
469
|
+
|
|
470
|
+
```typescript
|
|
471
|
+
import { CliModule, resolveCliModuleProvider } from '@qodalis/angular-cli';
|
|
472
|
+
import { weatherModule } from '@qodalis/cli-weather';
|
|
473
|
+
|
|
474
|
+
@NgModule({
|
|
475
|
+
imports: [CliModule],
|
|
476
|
+
providers: [resolveCliModuleProvider(weatherModule)],
|
|
477
|
+
})
|
|
478
|
+
export class AppModule {}
|
|
479
|
+
```
|
|
480
|
+
|
|
481
|
+
#### Angular (via template input)
|
|
482
|
+
|
|
483
|
+
```typescript
|
|
484
|
+
import { weatherModule } from '@qodalis/cli-weather';
|
|
485
|
+
|
|
486
|
+
export class AppComponent {
|
|
487
|
+
modules = [weatherModule];
|
|
488
|
+
}
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
```html
|
|
492
|
+
<cli [modules]="modules" />
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
#### React
|
|
496
|
+
|
|
497
|
+
```tsx
|
|
498
|
+
import { CliConfigProvider, Cli } from '@qodalis/react-cli';
|
|
499
|
+
import { weatherModule } from '@qodalis/cli-weather';
|
|
500
|
+
|
|
501
|
+
function App() {
|
|
502
|
+
return (
|
|
503
|
+
<CliConfigProvider modules={[weatherModule]}>
|
|
504
|
+
<Cli />
|
|
505
|
+
</CliConfigProvider>
|
|
506
|
+
);
|
|
507
|
+
}
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
#### Vue
|
|
511
|
+
|
|
512
|
+
```vue
|
|
513
|
+
<script setup lang="ts">
|
|
514
|
+
import { CliConfigProvider, Cli } from '@qodalis/vue-cli';
|
|
515
|
+
import { weatherModule } from '@qodalis/cli-weather';
|
|
516
|
+
</script>
|
|
517
|
+
|
|
518
|
+
<template>
|
|
519
|
+
<CliConfigProvider :modules="[weatherModule]">
|
|
520
|
+
<Cli />
|
|
521
|
+
</CliConfigProvider>
|
|
522
|
+
</template>
|
|
523
|
+
```
|
|
524
|
+
|
|
525
|
+
## Extending with Inline Commands
|
|
526
|
+
|
|
527
|
+
For quick one-off commands without creating a full plugin, implement `ICliCommandProcessor` directly in your app:
|
|
176
528
|
|
|
177
529
|
```typescript
|
|
178
530
|
import {
|
|
@@ -184,7 +536,7 @@ import {
|
|
|
184
536
|
export class GreetCommandProcessor implements ICliCommandProcessor {
|
|
185
537
|
command = 'greet';
|
|
186
538
|
description = 'Greet someone by name';
|
|
187
|
-
|
|
539
|
+
acceptsRawInput = true;
|
|
188
540
|
valueRequired = true;
|
|
189
541
|
|
|
190
542
|
async processCommand(
|
|
@@ -196,16 +548,14 @@ export class GreetCommandProcessor implements ICliCommandProcessor {
|
|
|
196
548
|
}
|
|
197
549
|
```
|
|
198
550
|
|
|
199
|
-
Register it
|
|
551
|
+
Register it with your framework (Angular: `resolveCommandProcessorProvider(GreetCommandProcessor)`, React/Vue: pass via `processors` prop), or wrap it in an inline `ICliModule`:
|
|
200
552
|
|
|
201
553
|
```typescript
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
})
|
|
208
|
-
export class AppModule {}
|
|
554
|
+
const myModule: ICliModule = {
|
|
555
|
+
apiVersion: 2,
|
|
556
|
+
name: 'my-app-commands',
|
|
557
|
+
processors: [new GreetCommandProcessor()],
|
|
558
|
+
};
|
|
209
559
|
```
|
|
210
560
|
|
|
211
561
|
```bash
|
|
@@ -213,14 +563,32 @@ export class AppModule {}
|
|
|
213
563
|
Hello, World!
|
|
214
564
|
```
|
|
215
565
|
|
|
566
|
+
## Using the Engine Directly
|
|
567
|
+
|
|
568
|
+
For advanced use cases or non-framework environments, use `CliEngine` directly:
|
|
569
|
+
|
|
570
|
+
```typescript
|
|
571
|
+
import { CliEngine } from '@qodalis/cli';
|
|
572
|
+
|
|
573
|
+
const engine = new CliEngine(document.getElementById('terminal')!, {
|
|
574
|
+
welcomeMessage: { message: 'Welcome!', show: 'always' },
|
|
575
|
+
});
|
|
576
|
+
|
|
577
|
+
engine.registerProcessors([new GreetCommandProcessor()]);
|
|
578
|
+
await engine.start();
|
|
579
|
+
```
|
|
580
|
+
|
|
216
581
|
## Features
|
|
217
582
|
|
|
218
|
-
- **
|
|
583
|
+
- **Multi-framework** — Angular, React, Vue, or vanilla JS
|
|
584
|
+
- **Command chaining** with `&&`, `||`, `|`, and `>>` operators
|
|
219
585
|
- **Command history** with arrow key navigation
|
|
220
586
|
- **Tab-like completions** and keyboard shortcuts (`Ctrl+C`, `Ctrl+L`, `Escape`)
|
|
221
587
|
- **Theming** with built-in themes and custom color support
|
|
222
588
|
- **User sessions** with multi-user support
|
|
223
589
|
- **State persistence** across sessions
|
|
590
|
+
- **Interactive prompts** with live preview (select menus with real-time feedback)
|
|
591
|
+
- **Full-screen mode API** for rich TUI commands
|
|
224
592
|
- **Progress bars, spinners, and text animations**
|
|
225
593
|
- **Runtime package installation** from npm
|
|
226
594
|
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qodalis/cli-core",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "Core
|
|
3
|
+
"version": "2.0.0-beta.1",
|
|
4
|
+
"description": "Core interfaces, types, and utilities for the @qodalis CLI ecosystem.",
|
|
5
5
|
"author": "Nicolae Lupei, Qodalis Solutions",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "https://github.com/qodalis-solutions/
|
|
9
|
+
"url": "https://github.com/qodalis-solutions/web-cli"
|
|
10
10
|
},
|
|
11
11
|
"homepage": "https://qodalis.com",
|
|
12
12
|
"keywords": [
|
|
@@ -14,29 +14,22 @@
|
|
|
14
14
|
"cli",
|
|
15
15
|
"qodalis",
|
|
16
16
|
"terminal",
|
|
17
|
-
"
|
|
17
|
+
"interfaces",
|
|
18
|
+
"types",
|
|
18
19
|
"extensions"
|
|
19
20
|
],
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
"main": "./public-api.js",
|
|
22
|
+
"module": "./public-api.mjs",
|
|
23
|
+
"types": "./public-api.d.ts",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./public-api.d.ts",
|
|
27
|
+
"import": "./public-api.mjs",
|
|
28
|
+
"require": "./public-api.js"
|
|
29
|
+
}
|
|
23
30
|
},
|
|
24
31
|
"dependencies": {
|
|
25
|
-
"tslib": "^2.3.0",
|
|
26
32
|
"@xterm/xterm": "^5.5.0"
|
|
27
33
|
},
|
|
28
|
-
"sideEffects": false
|
|
29
|
-
|
|
30
|
-
"typings": "index.d.ts",
|
|
31
|
-
"exports": {
|
|
32
|
-
"./package.json": {
|
|
33
|
-
"default": "./package.json"
|
|
34
|
-
},
|
|
35
|
-
".": {
|
|
36
|
-
"types": "./index.d.ts",
|
|
37
|
-
"esm2022": "./esm2022/qodalis-cli-core.mjs",
|
|
38
|
-
"esm": "./esm2022/qodalis-cli-core.mjs",
|
|
39
|
-
"default": "./fesm2022/qodalis-cli-core.mjs"
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
34
|
+
"sideEffects": false
|
|
35
|
+
}
|