@qodalis/cli 2.0.0-rc.2 → 2.0.0-rc.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qodalis/cli",
3
- "version": "2.0.0-rc.2",
3
+ "version": "2.0.0-rc.4",
4
4
  "description": "Framework-agnostic CLI engine for @qodalis terminal applications.",
5
5
  "author": "Nicolae Lupei, Qodalis Solutions",
6
6
  "license": "MIT",
@@ -30,7 +30,7 @@
30
30
  "./assets/*": "./assets/*"
31
31
  },
32
32
  "dependencies": {
33
- "@qodalis/cli-core": "2.0.0-rc.2",
33
+ "@qodalis/cli-core": "2.0.0-rc.4",
34
34
  "@xterm/xterm": "^6.0.0",
35
35
  "@xterm/addon-fit": "^0.11.0",
36
36
  "@xterm/addon-web-links": "^0.12.0",
package/public-api.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { ICliCommandProcessor, ICliCommandParameterDescriptor as ICliCommandParameterDescriptor$1, ICliCommandProcessorRegistry, ICliCommandChildProcessor, CliProcessorMetadata, CliStateConfiguration, ICliExecutionContext, CliProcessCommand, ICliCommandAuthor, CliThemeInfo, ICliExecutionProcess, ICliUserSession, ICliSpinner, ICliPercentageProgressBar, ICliTextAnimator, ICliTerminalWriter, ICliCommandExecutorService, ICliClipboard, ICliStateStore, CliOptions, ICliLogger, ICliServiceProvider, ICliTranslationService, ICliInputReader, ICliBackgroundServiceRegistry, ICliHttpClient, ICliNotifier, ICliManagedInterval, ICliManagedTimer, ICliEventBus, ICliKeyValueStore, CliStateStoreOptions, ICliCompletionProvider, ICliFilePickerProvider, CliFullScreenOptions, ICliProcessRegistry, ICliBackgroundService, ICliServiceContext, ICliBackgroundServiceInfo, ICliServiceLogEntry, CliServiceEventHandler, ICliGlobalParameterHandler, CliForegroundColor, CliBackgroundColor, CliToken, CliProvider, CliTableOptions, CliLogLevel, CliPercentageProgressBarUpdateValueOptions, CliTextAnimatorOptions, ICliModule, CliModuleRegistry, Package, ICliPingServerService, CliLineOptions, CliSelectOption, CliSelectOptions, CliMultiSelectOption, CliMultiSelectOptions, CliNumberOptions, CliDateOptions, CliFilePickerOptions, CliFileResult, ICliProcessRegisterOptions, ICliProcessEntry, ICliDragDropService, CliHttpRequestOptions, CliNotification, ICliPermissionRegistry, CliPermissionDefinition, CliState, CliEngineSnapshot, CliEvent, CliEventType, CliEventMap, CliEmitOptions, CustomEventType, CliEventHandler, CliServerConfig, ICliServerAuthService, CliServerCommandDescriptor, CliServerCapabilities, CliServerResponse, CliServerOutput, CliPanelPosition, CliPanelConfig, CliPanelHideAlignment, ICliPanelRef, CliPanelState } from '@qodalis/cli-core';
1
+ import { ICliCommandProcessor, ICliCommandParameterDescriptor as ICliCommandParameterDescriptor$1, ICliCommandProcessorRegistry, ICliCommandChildProcessor, CliProcessorMetadata, CliStateConfiguration, ICliExecutionContext, CliProcessCommand, ICliCommandAuthor, ICliCommandControls, CliThemeInfo, ICliExecutionProcess, ICliUserSession, ICliSpinner, ICliPercentageProgressBar, ICliTextAnimator, ICliTerminalWriter, ICliCommandExecutorService, ICliClipboard, ICliStateStore, CliOptions, ICliLogger, ICliServiceProvider, ICliTranslationService, ICliInputReader, ICliBackgroundServiceRegistry, ICliHttpClient, ICliNotifier, ICliManagedInterval, ICliManagedTimer, ICliEventBus, ICliKeyValueStore, CliStateStoreOptions, ICliCompletionProvider, ICliFilePickerProvider, CliFullScreenOptions, ICliProcessRegistry, ICliBackgroundService, ICliServiceContext, ICliBackgroundServiceInfo, ICliServiceLogEntry, CliServiceEventHandler, ICliGlobalParameterHandler, CliForegroundColor, CliBackgroundColor, CliToken, CliProvider, CliTableOptions, CliLogLevel, CliPercentageProgressBarUpdateValueOptions, CliTextAnimatorOptions, ICliModule, CliModuleRegistry, Package, ICliPingServerService, CliLineOptions, CliSelectOption, CliSelectOptions, CliMultiSelectOption, CliMultiSelectOptions, CliNumberOptions, CliDateOptions, CliFilePickerOptions, CliFileResult, ICliProcessRegisterOptions, ICliProcessEntry, ICliDragDropService, CliHttpRequestOptions, CliNotification, ICliPermissionRegistry, CliPermissionDefinition, CliState, CliEngineSnapshot, CliEvent, CliEventType, CliEventMap, CliEmitOptions, CustomEventType, CliEventHandler, CliServerConfig, ICliServerAuthService, CliServerCommandDescriptor, CliServerCapabilities, CliServerResponse, CliServerOutput, CliPanelPosition, CliPanelConfig, CliPanelHideAlignment, ICliPanelRef, CliPanelState } from '@qodalis/cli-core';
2
2
  export { ICliUserSessionService_TOKEN, ICliUsersStoreService_TOKEN } from '@qodalis/cli-core';
3
3
  import { ITheme, Terminal, ITerminalAddon, ITerminalOptions, ITerminalInitOnlyOptions } from '@xterm/xterm';
4
4
  import * as rxjs from 'rxjs';
@@ -165,7 +165,7 @@ declare const CliKeyValueStore_TOKEN: any;
165
165
  */
166
166
  declare const SyntaxHighlighterRegistry_TOKEN: any;
167
167
 
168
- declare const LIBRARY_VERSION = "2.0.0-rc.2";
168
+ declare const LIBRARY_VERSION = "2.0.0-rc.4";
169
169
  declare const API_VERSION = 2;
170
170
 
171
171
  declare class CliAliasCommandProcessor implements ICliCommandProcessor {
@@ -655,6 +655,7 @@ declare class CliNanoCommandProcessor implements ICliCommandProcessor {
655
655
  author: any;
656
656
  acceptsRawInput: boolean;
657
657
  metadata: CliProcessorMetadata;
658
+ controls: ICliCommandControls;
658
659
  private buffer;
659
660
  private renderer;
660
661
  private filePath;
@@ -740,6 +741,7 @@ declare class CliKillCommandProcessor implements ICliCommandProcessor {
740
741
 
741
742
  declare class CliHtopCommandProcessor implements ICliCommandProcessor {
742
743
  command: string;
744
+ controls: ICliCommandControls;
743
745
  description: string;
744
746
  author: any;
745
747
  metadata?: CliProcessorMetadata;
@@ -3334,6 +3336,7 @@ declare class CliServerCommandProcessor implements ICliCommandProcessor {
3334
3336
 
3335
3337
  declare class CliSshCommandProcessor implements ICliCommandProcessor {
3336
3338
  command: string;
3339
+ controls: ICliCommandControls;
3337
3340
  aliases: string[];
3338
3341
  description: string;
3339
3342
  acceptsRawInput: boolean;
package/public-api.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ICliCommandProcessor, ICliCommandParameterDescriptor as ICliCommandParameterDescriptor$1, ICliCommandProcessorRegistry, ICliCommandChildProcessor, CliProcessorMetadata, CliStateConfiguration, ICliExecutionContext, CliProcessCommand, ICliCommandAuthor, CliThemeInfo, ICliExecutionProcess, ICliUserSession, ICliSpinner, ICliPercentageProgressBar, ICliTextAnimator, ICliTerminalWriter, ICliCommandExecutorService, ICliClipboard, ICliStateStore, CliOptions, ICliLogger, ICliServiceProvider, ICliTranslationService, ICliInputReader, ICliBackgroundServiceRegistry, ICliHttpClient, ICliNotifier, ICliManagedInterval, ICliManagedTimer, ICliEventBus, ICliKeyValueStore, CliStateStoreOptions, ICliCompletionProvider, ICliFilePickerProvider, CliFullScreenOptions, ICliProcessRegistry, ICliBackgroundService, ICliServiceContext, ICliBackgroundServiceInfo, ICliServiceLogEntry, CliServiceEventHandler, ICliGlobalParameterHandler, CliForegroundColor, CliBackgroundColor, CliToken, CliProvider, CliTableOptions, CliLogLevel, CliPercentageProgressBarUpdateValueOptions, CliTextAnimatorOptions, ICliModule, CliModuleRegistry, Package, ICliPingServerService, CliLineOptions, CliSelectOption, CliSelectOptions, CliMultiSelectOption, CliMultiSelectOptions, CliNumberOptions, CliDateOptions, CliFilePickerOptions, CliFileResult, ICliProcessRegisterOptions, ICliProcessEntry, ICliDragDropService, CliHttpRequestOptions, CliNotification, ICliPermissionRegistry, CliPermissionDefinition, CliState, CliEngineSnapshot, CliEvent, CliEventType, CliEventMap, CliEmitOptions, CustomEventType, CliEventHandler, CliServerConfig, ICliServerAuthService, CliServerCommandDescriptor, CliServerCapabilities, CliServerResponse, CliServerOutput, CliPanelPosition, CliPanelConfig, CliPanelHideAlignment, ICliPanelRef, CliPanelState } from '@qodalis/cli-core';
1
+ import { ICliCommandProcessor, ICliCommandParameterDescriptor as ICliCommandParameterDescriptor$1, ICliCommandProcessorRegistry, ICliCommandChildProcessor, CliProcessorMetadata, CliStateConfiguration, ICliExecutionContext, CliProcessCommand, ICliCommandAuthor, ICliCommandControls, CliThemeInfo, ICliExecutionProcess, ICliUserSession, ICliSpinner, ICliPercentageProgressBar, ICliTextAnimator, ICliTerminalWriter, ICliCommandExecutorService, ICliClipboard, ICliStateStore, CliOptions, ICliLogger, ICliServiceProvider, ICliTranslationService, ICliInputReader, ICliBackgroundServiceRegistry, ICliHttpClient, ICliNotifier, ICliManagedInterval, ICliManagedTimer, ICliEventBus, ICliKeyValueStore, CliStateStoreOptions, ICliCompletionProvider, ICliFilePickerProvider, CliFullScreenOptions, ICliProcessRegistry, ICliBackgroundService, ICliServiceContext, ICliBackgroundServiceInfo, ICliServiceLogEntry, CliServiceEventHandler, ICliGlobalParameterHandler, CliForegroundColor, CliBackgroundColor, CliToken, CliProvider, CliTableOptions, CliLogLevel, CliPercentageProgressBarUpdateValueOptions, CliTextAnimatorOptions, ICliModule, CliModuleRegistry, Package, ICliPingServerService, CliLineOptions, CliSelectOption, CliSelectOptions, CliMultiSelectOption, CliMultiSelectOptions, CliNumberOptions, CliDateOptions, CliFilePickerOptions, CliFileResult, ICliProcessRegisterOptions, ICliProcessEntry, ICliDragDropService, CliHttpRequestOptions, CliNotification, ICliPermissionRegistry, CliPermissionDefinition, CliState, CliEngineSnapshot, CliEvent, CliEventType, CliEventMap, CliEmitOptions, CustomEventType, CliEventHandler, CliServerConfig, ICliServerAuthService, CliServerCommandDescriptor, CliServerCapabilities, CliServerResponse, CliServerOutput, CliPanelPosition, CliPanelConfig, CliPanelHideAlignment, ICliPanelRef, CliPanelState } from '@qodalis/cli-core';
2
2
  export { ICliUserSessionService_TOKEN, ICliUsersStoreService_TOKEN } from '@qodalis/cli-core';
3
3
  import { ITheme, Terminal, ITerminalAddon, ITerminalOptions, ITerminalInitOnlyOptions } from '@xterm/xterm';
4
4
  import * as rxjs from 'rxjs';
@@ -165,7 +165,7 @@ declare const CliKeyValueStore_TOKEN: any;
165
165
  */
166
166
  declare const SyntaxHighlighterRegistry_TOKEN: any;
167
167
 
168
- declare const LIBRARY_VERSION = "2.0.0-rc.2";
168
+ declare const LIBRARY_VERSION = "2.0.0-rc.4";
169
169
  declare const API_VERSION = 2;
170
170
 
171
171
  declare class CliAliasCommandProcessor implements ICliCommandProcessor {
@@ -655,6 +655,7 @@ declare class CliNanoCommandProcessor implements ICliCommandProcessor {
655
655
  author: any;
656
656
  acceptsRawInput: boolean;
657
657
  metadata: CliProcessorMetadata;
658
+ controls: ICliCommandControls;
658
659
  private buffer;
659
660
  private renderer;
660
661
  private filePath;
@@ -740,6 +741,7 @@ declare class CliKillCommandProcessor implements ICliCommandProcessor {
740
741
 
741
742
  declare class CliHtopCommandProcessor implements ICliCommandProcessor {
742
743
  command: string;
744
+ controls: ICliCommandControls;
743
745
  description: string;
744
746
  author: any;
745
747
  metadata?: CliProcessorMetadata;
@@ -3334,6 +3336,7 @@ declare class CliServerCommandProcessor implements ICliCommandProcessor {
3334
3336
 
3335
3337
  declare class CliSshCommandProcessor implements ICliCommandProcessor {
3336
3338
  command: string;
3339
+ controls: ICliCommandControls;
3337
3340
  aliases: string[];
3338
3341
  description: string;
3339
3342
  acceptsRawInput: boolean;
package/public-api.js CHANGED
@@ -519,7 +519,7 @@ var CliKeyValueStore_TOKEN = cliCore.createCliToken("cli-key-value-store");
519
519
  var SyntaxHighlighterRegistry_TOKEN = cliCore.createCliToken("syntax-highlighter-registry");
520
520
 
521
521
  // src/lib/version.ts
522
- var LIBRARY_VERSION = "2.0.0-rc.2";
522
+ var LIBRARY_VERSION = "2.0.0-rc.4";
523
523
  var API_VERSION = 2;
524
524
  var ANONYMOUS = "\0anonymous";
525
525
  function aliasOwner(context2) {
@@ -10155,6 +10155,26 @@ var CliNanoCommandProcessor = class {
10155
10155
  icon: "\u{1F4DD}",
10156
10156
  module: "system"
10157
10157
  };
10158
+ this.controls = {
10159
+ textInput: true,
10160
+ keys: [
10161
+ { label: "Save", key: "Ctrl+S", data: cliCore.CliKeyData.ctrl("s"), description: "Save the file" },
10162
+ { label: "Exit", key: "Ctrl+X", data: cliCore.CliKeyData.ctrl("x"), description: "Exit (asks to save changes)" },
10163
+ { label: "Find", key: "Ctrl+W", data: cliCore.CliKeyData.ctrl("w"), description: "Search" },
10164
+ { label: "Cut", key: "Ctrl+K", data: cliCore.CliKeyData.ctrl("k"), description: "Cut the line" },
10165
+ { label: "Paste", key: "Ctrl+U", data: cliCore.CliKeyData.ctrl("u"), description: "Paste the cut text" },
10166
+ { label: "Help", key: "Ctrl+G", data: cliCore.CliKeyData.ctrl("g"), description: "Show the help" },
10167
+ { label: "Esc", key: "Esc", data: cliCore.CliKeyData.escape, description: "Cancel a prompt" },
10168
+ { label: "\u2190", key: "Left", data: cliCore.CliKeyData.left, description: "Left", repeat: true },
10169
+ { label: "\u2191", key: "Up", data: cliCore.CliKeyData.up, description: "Up", repeat: true },
10170
+ { label: "\u2193", key: "Down", data: cliCore.CliKeyData.down, description: "Down", repeat: true },
10171
+ { label: "\u2192", key: "Right", data: cliCore.CliKeyData.right, description: "Right", repeat: true },
10172
+ { label: "Home", key: "Home", data: cliCore.CliKeyData.home, description: "Start of the line" },
10173
+ { label: "End", key: "End", data: cliCore.CliKeyData.end, description: "End of the line" },
10174
+ { label: "PgUp", key: "PageUp", data: cliCore.CliKeyData.pageUp, description: "Page up", repeat: true },
10175
+ { label: "PgDn", key: "PageDown", data: cliCore.CliKeyData.pageDown, description: "Page down", repeat: true }
10176
+ ]
10177
+ };
10158
10178
  this.filePath = null;
10159
10179
  this.fs = null;
10160
10180
  this.resizeDisposable = null;
@@ -11525,6 +11545,18 @@ function pad(str, len) {
11525
11545
  var CliHtopCommandProcessor = class {
11526
11546
  constructor() {
11527
11547
  this.command = "htop";
11548
+ this.controls = {
11549
+ keys: [
11550
+ { label: "\u2191", key: "Up", data: cliCore.CliKeyData.up, description: "Select the previous process", repeat: true },
11551
+ { label: "\u2193", key: "Down", data: cliCore.CliKeyData.down, description: "Select the next process", repeat: true },
11552
+ { label: "KILL", key: "K", data: "k", description: "Kill the process" },
11553
+ { label: "START", key: "S", data: "s", description: "Start the service" },
11554
+ { label: "STOP", key: "T", data: "t", description: "Stop the service" },
11555
+ { label: "RESTART", key: "R", data: "r", description: "Restart the service" },
11556
+ { label: "LOGS", key: "L", data: "l", description: "Show the logs" },
11557
+ { label: "Q", key: "Q", data: "q", description: "Quit" }
11558
+ ]
11559
+ };
11528
11560
  this.description = "Interactive process and service monitor";
11529
11561
  this.author = cliCore.DefaultLibraryAuthor;
11530
11562
  this.metadata = {
@@ -21271,6 +21303,20 @@ var ServerDefaultProcessor = class {
21271
21303
  var CliSshCommandProcessor = class {
21272
21304
  constructor() {
21273
21305
  this.command = "ssh";
21306
+ this.controls = {
21307
+ textInput: true,
21308
+ keys: [
21309
+ { label: "ESC", key: "Esc", data: cliCore.CliKeyData.escape, description: "Escape" },
21310
+ { label: "TAB", key: "Tab", data: " ", description: "Complete" },
21311
+ { label: "^C", key: "Ctrl+C", data: cliCore.CliKeyData.ctrl("c"), description: "Interrupt" },
21312
+ { label: "^D", key: "Ctrl+D", data: cliCore.CliKeyData.ctrl("d"), description: "End of input" },
21313
+ { label: "^L", key: "Ctrl+L", data: cliCore.CliKeyData.ctrl("l"), description: "Clear the screen" },
21314
+ { label: "\u2190", key: "Left", data: cliCore.CliKeyData.left, description: "Left", repeat: true },
21315
+ { label: "\u2191", key: "Up", data: cliCore.CliKeyData.up, description: "Up", repeat: true },
21316
+ { label: "\u2193", key: "Down", data: cliCore.CliKeyData.down, description: "Down", repeat: true },
21317
+ { label: "\u2192", key: "Right", data: cliCore.CliKeyData.right, description: "Right", repeat: true }
21318
+ ]
21319
+ };
21274
21320
  this.aliases = ["shell"];
21275
21321
  this.description = "Open a remote shell session on a server";
21276
21322
  this.acceptsRawInput = true;
@@ -22139,6 +22185,50 @@ async function initializeServices(options) {
22139
22185
  };
22140
22186
  }
22141
22187
 
22188
+ // src/lib/completion/cli-completion-path.ts
22189
+ function resolveCompletionPath(tokens, tokenIndex, processors, currentToken = "") {
22190
+ const parsed = tokens.slice(0, tokenIndex).map(toParsedToken);
22191
+ let processor;
22192
+ let descriptors = [];
22193
+ let candidates = processors;
22194
+ let isFlagValue = false;
22195
+ for (let i = 0; i < parsed.length; i++) {
22196
+ const token = parsed[i];
22197
+ if (token.kind === "flag") {
22198
+ if (!flagTakesNextWord(token, descriptors)) continue;
22199
+ if (i + 1 < parsed.length) {
22200
+ if (parsed[i + 1].kind === "word") i++;
22201
+ } else if (!currentToken.startsWith("-")) {
22202
+ isFlagValue = true;
22203
+ }
22204
+ continue;
22205
+ }
22206
+ const name = token.value.toLowerCase();
22207
+ const match = candidates?.find(
22208
+ (p) => p.command.toLowerCase() === name || p.aliases?.some((a) => a.toLowerCase() === name)
22209
+ );
22210
+ if (match) {
22211
+ processor = match;
22212
+ descriptors = [...match.parameters ?? [], ...descriptors];
22213
+ }
22214
+ candidates = match?.processors?.length ? match.processors : void 0;
22215
+ }
22216
+ return { processor, descriptors, subCommands: candidates, isFlagValue };
22217
+ }
22218
+ function toParsedToken(text) {
22219
+ const flag = /^(--?)([a-zA-Z0-9_][^\s=]*)(=.*)?$/.exec(text);
22220
+ if (!flag) {
22221
+ return { kind: "word", value: text };
22222
+ }
22223
+ return {
22224
+ kind: "flag",
22225
+ name: flag[2],
22226
+ value: flag[3]?.slice(1) ?? true,
22227
+ hasEquals: flag[3] !== void 0,
22228
+ ...flag[1] === "-" ? { short: true } : {}
22229
+ };
22230
+ }
22231
+
22142
22232
  // src/lib/completion/cli-command-completion-provider.ts
22143
22233
  var CliCommandCompletionProvider = class {
22144
22234
  constructor(registry) {
@@ -22150,22 +22240,16 @@ var CliCommandCompletionProvider = class {
22150
22240
  if (tokenIndex === 0) {
22151
22241
  return this.getCommandNames(this.registry.processors, token);
22152
22242
  }
22153
- const mainCommand = tokens[0];
22154
- const processor = this.registry.findProcessor(mainCommand, []);
22155
- if (!processor?.processors?.length) {
22243
+ const path = resolveCompletionPath(
22244
+ tokens,
22245
+ tokenIndex,
22246
+ this.registry.processors,
22247
+ token
22248
+ );
22249
+ if (path.isFlagValue || !path.subCommands) {
22156
22250
  return [];
22157
22251
  }
22158
- let current = processor;
22159
- for (let i = 1; i < tokenIndex; i++) {
22160
- const sub = current.processors?.find(
22161
- (p) => p.command === tokens[i]
22162
- );
22163
- if (!sub?.processors?.length) {
22164
- return [];
22165
- }
22166
- current = sub;
22167
- }
22168
- return this.getCommandNames(current.processors ?? [], token);
22252
+ return this.getCommandNames(path.subCommands, token);
22169
22253
  }
22170
22254
  getCommandNames(processors, prefix) {
22171
22255
  const names = [];
@@ -22187,24 +22271,24 @@ var CliParameterCompletionProvider = class {
22187
22271
  this.priority = 200;
22188
22272
  }
22189
22273
  getCompletions(context2) {
22190
- const { tokens, token } = context2;
22274
+ const { tokens, tokenIndex, token } = context2;
22191
22275
  if (!token.startsWith("-")) {
22192
22276
  return [];
22193
22277
  }
22194
22278
  if (tokens.length === 0) {
22195
22279
  return [];
22196
22280
  }
22197
- const mainCommand = tokens[0];
22198
- const chainCommands = tokens.slice(1).filter((t) => !t.startsWith("-"));
22199
- const processor = this.registry.findProcessorInCollection(
22200
- mainCommand,
22201
- chainCommands,
22202
- this.registry.processors
22281
+ const path = resolveCompletionPath(
22282
+ tokens,
22283
+ tokenIndex,
22284
+ this.registry.processors,
22285
+ token
22203
22286
  );
22287
+ const seen = /* @__PURE__ */ new Set();
22204
22288
  const allParameters = [
22205
- ...processor?.parameters ?? [],
22289
+ ...path.descriptors,
22206
22290
  ...this.executor.getGlobalParameters()
22207
- ];
22291
+ ].filter((p) => !seen.has(p.name) && !!seen.add(p.name));
22208
22292
  if (allParameters.length === 0) {
22209
22293
  return [];
22210
22294
  }