@qodalis/cli 2.0.0-rc.3 → 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/public-api.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { createCliToken, CliLogLevel, DefaultThemes, DefaultThemeInfos, CliForegroundColor, DefaultLibraryAuthor, CliIcon, writeWrapped, LIBRARY_VERSION as LIBRARY_VERSION$1, writeUsage, writeExamples, writeHint, joinShellWords, unquoteRawArgument, resolveConfigurationCategories, ICliTranslationService_TOKEN, splitShellWords, cliAuthorize, CliUsersPermissions, ICliAuthorizationService_TOKEN, quoteShellWord, resolveHeaders, appendQueryParams, buildAuthenticatedWebSocketUrl, ServerVersionNegotiator, CliHttpError, formatJson, visibleLength, ICliEventBus_TOKEN, stripAnsi, CancellablePromise, isCliAccessDeniedError, getParameterValue, ICliCommandGuard_TOKEN, getRightOfWord, CLI_CONFIGURE_STORE_NAME, CliModuleRegistry, initializeBrowserEnvironment, ICliPermissionRegistry_TOKEN, satisfiesVersionRange, CliServerPermissions, ICliDragDropService_TOKEN, cliAccessMetadataGuards, ICliServerAuthService_TOKEN, loadPanelPosition, savePanelPosition, derivePanelThemeStyles, delay, colorFirstWord, clearTerminalLine, ICliCompletionProvider_TOKEN, ICliServerAuthTokenProvider_TOKEN, truncateToWidth } from '@qodalis/cli-core';
1
+ import { createCliToken, CliLogLevel, DefaultThemes, DefaultThemeInfos, CliForegroundColor, DefaultLibraryAuthor, CliIcon, writeWrapped, LIBRARY_VERSION as LIBRARY_VERSION$1, writeUsage, writeExamples, writeHint, joinShellWords, CliKeyData, unquoteRawArgument, resolveConfigurationCategories, ICliTranslationService_TOKEN, splitShellWords, cliAuthorize, CliUsersPermissions, ICliAuthorizationService_TOKEN, quoteShellWord, resolveHeaders, appendQueryParams, buildAuthenticatedWebSocketUrl, ServerVersionNegotiator, CliHttpError, formatJson, visibleLength, ICliEventBus_TOKEN, stripAnsi, CancellablePromise, isCliAccessDeniedError, getParameterValue, ICliCommandGuard_TOKEN, getRightOfWord, CLI_CONFIGURE_STORE_NAME, CliModuleRegistry, initializeBrowserEnvironment, ICliPermissionRegistry_TOKEN, satisfiesVersionRange, CliServerPermissions, ICliDragDropService_TOKEN, cliAccessMetadataGuards, ICliServerAuthService_TOKEN, loadPanelPosition, savePanelPosition, derivePanelThemeStyles, delay, colorFirstWord, clearTerminalLine, ICliCompletionProvider_TOKEN, ICliServerAuthTokenProvider_TOKEN, truncateToWidth } from '@qodalis/cli-core';
2
2
  export { ICliUserSessionService_TOKEN, ICliUsersStoreService_TOKEN } from '@qodalis/cli-core';
3
3
  import { Terminal } from '@xterm/xterm';
4
4
  import { FitAddon } from '@xterm/addon-fit';
@@ -518,7 +518,7 @@ var CliKeyValueStore_TOKEN = createCliToken("cli-key-value-store");
518
518
  var SyntaxHighlighterRegistry_TOKEN = createCliToken("syntax-highlighter-registry");
519
519
 
520
520
  // src/lib/version.ts
521
- var LIBRARY_VERSION = "2.0.0-rc.3";
521
+ var LIBRARY_VERSION = "2.0.0-rc.4";
522
522
  var API_VERSION = 2;
523
523
  var ANONYMOUS = "\0anonymous";
524
524
  function aliasOwner(context2) {
@@ -10154,6 +10154,26 @@ var CliNanoCommandProcessor = class {
10154
10154
  icon: "\u{1F4DD}",
10155
10155
  module: "system"
10156
10156
  };
10157
+ this.controls = {
10158
+ textInput: true,
10159
+ keys: [
10160
+ { label: "Save", key: "Ctrl+S", data: CliKeyData.ctrl("s"), description: "Save the file" },
10161
+ { label: "Exit", key: "Ctrl+X", data: CliKeyData.ctrl("x"), description: "Exit (asks to save changes)" },
10162
+ { label: "Find", key: "Ctrl+W", data: CliKeyData.ctrl("w"), description: "Search" },
10163
+ { label: "Cut", key: "Ctrl+K", data: CliKeyData.ctrl("k"), description: "Cut the line" },
10164
+ { label: "Paste", key: "Ctrl+U", data: CliKeyData.ctrl("u"), description: "Paste the cut text" },
10165
+ { label: "Help", key: "Ctrl+G", data: CliKeyData.ctrl("g"), description: "Show the help" },
10166
+ { label: "Esc", key: "Esc", data: CliKeyData.escape, description: "Cancel a prompt" },
10167
+ { label: "\u2190", key: "Left", data: CliKeyData.left, description: "Left", repeat: true },
10168
+ { label: "\u2191", key: "Up", data: CliKeyData.up, description: "Up", repeat: true },
10169
+ { label: "\u2193", key: "Down", data: CliKeyData.down, description: "Down", repeat: true },
10170
+ { label: "\u2192", key: "Right", data: CliKeyData.right, description: "Right", repeat: true },
10171
+ { label: "Home", key: "Home", data: CliKeyData.home, description: "Start of the line" },
10172
+ { label: "End", key: "End", data: CliKeyData.end, description: "End of the line" },
10173
+ { label: "PgUp", key: "PageUp", data: CliKeyData.pageUp, description: "Page up", repeat: true },
10174
+ { label: "PgDn", key: "PageDown", data: CliKeyData.pageDown, description: "Page down", repeat: true }
10175
+ ]
10176
+ };
10157
10177
  this.filePath = null;
10158
10178
  this.fs = null;
10159
10179
  this.resizeDisposable = null;
@@ -11524,6 +11544,18 @@ function pad(str, len) {
11524
11544
  var CliHtopCommandProcessor = class {
11525
11545
  constructor() {
11526
11546
  this.command = "htop";
11547
+ this.controls = {
11548
+ keys: [
11549
+ { label: "\u2191", key: "Up", data: CliKeyData.up, description: "Select the previous process", repeat: true },
11550
+ { label: "\u2193", key: "Down", data: CliKeyData.down, description: "Select the next process", repeat: true },
11551
+ { label: "KILL", key: "K", data: "k", description: "Kill the process" },
11552
+ { label: "START", key: "S", data: "s", description: "Start the service" },
11553
+ { label: "STOP", key: "T", data: "t", description: "Stop the service" },
11554
+ { label: "RESTART", key: "R", data: "r", description: "Restart the service" },
11555
+ { label: "LOGS", key: "L", data: "l", description: "Show the logs" },
11556
+ { label: "Q", key: "Q", data: "q", description: "Quit" }
11557
+ ]
11558
+ };
11527
11559
  this.description = "Interactive process and service monitor";
11528
11560
  this.author = DefaultLibraryAuthor;
11529
11561
  this.metadata = {
@@ -21270,6 +21302,20 @@ var ServerDefaultProcessor = class {
21270
21302
  var CliSshCommandProcessor = class {
21271
21303
  constructor() {
21272
21304
  this.command = "ssh";
21305
+ this.controls = {
21306
+ textInput: true,
21307
+ keys: [
21308
+ { label: "ESC", key: "Esc", data: CliKeyData.escape, description: "Escape" },
21309
+ { label: "TAB", key: "Tab", data: " ", description: "Complete" },
21310
+ { label: "^C", key: "Ctrl+C", data: CliKeyData.ctrl("c"), description: "Interrupt" },
21311
+ { label: "^D", key: "Ctrl+D", data: CliKeyData.ctrl("d"), description: "End of input" },
21312
+ { label: "^L", key: "Ctrl+L", data: CliKeyData.ctrl("l"), description: "Clear the screen" },
21313
+ { label: "\u2190", key: "Left", data: CliKeyData.left, description: "Left", repeat: true },
21314
+ { label: "\u2191", key: "Up", data: CliKeyData.up, description: "Up", repeat: true },
21315
+ { label: "\u2193", key: "Down", data: CliKeyData.down, description: "Down", repeat: true },
21316
+ { label: "\u2192", key: "Right", data: CliKeyData.right, description: "Right", repeat: true }
21317
+ ]
21318
+ };
21273
21319
  this.aliases = ["shell"];
21274
21320
  this.description = "Open a remote shell session on a server";
21275
21321
  this.acceptsRawInput = true;
@@ -22138,6 +22184,50 @@ async function initializeServices(options) {
22138
22184
  };
22139
22185
  }
22140
22186
 
22187
+ // src/lib/completion/cli-completion-path.ts
22188
+ function resolveCompletionPath(tokens, tokenIndex, processors, currentToken = "") {
22189
+ const parsed = tokens.slice(0, tokenIndex).map(toParsedToken);
22190
+ let processor;
22191
+ let descriptors = [];
22192
+ let candidates = processors;
22193
+ let isFlagValue = false;
22194
+ for (let i = 0; i < parsed.length; i++) {
22195
+ const token = parsed[i];
22196
+ if (token.kind === "flag") {
22197
+ if (!flagTakesNextWord(token, descriptors)) continue;
22198
+ if (i + 1 < parsed.length) {
22199
+ if (parsed[i + 1].kind === "word") i++;
22200
+ } else if (!currentToken.startsWith("-")) {
22201
+ isFlagValue = true;
22202
+ }
22203
+ continue;
22204
+ }
22205
+ const name = token.value.toLowerCase();
22206
+ const match = candidates?.find(
22207
+ (p) => p.command.toLowerCase() === name || p.aliases?.some((a) => a.toLowerCase() === name)
22208
+ );
22209
+ if (match) {
22210
+ processor = match;
22211
+ descriptors = [...match.parameters ?? [], ...descriptors];
22212
+ }
22213
+ candidates = match?.processors?.length ? match.processors : void 0;
22214
+ }
22215
+ return { processor, descriptors, subCommands: candidates, isFlagValue };
22216
+ }
22217
+ function toParsedToken(text) {
22218
+ const flag = /^(--?)([a-zA-Z0-9_][^\s=]*)(=.*)?$/.exec(text);
22219
+ if (!flag) {
22220
+ return { kind: "word", value: text };
22221
+ }
22222
+ return {
22223
+ kind: "flag",
22224
+ name: flag[2],
22225
+ value: flag[3]?.slice(1) ?? true,
22226
+ hasEquals: flag[3] !== void 0,
22227
+ ...flag[1] === "-" ? { short: true } : {}
22228
+ };
22229
+ }
22230
+
22141
22231
  // src/lib/completion/cli-command-completion-provider.ts
22142
22232
  var CliCommandCompletionProvider = class {
22143
22233
  constructor(registry) {
@@ -22149,22 +22239,16 @@ var CliCommandCompletionProvider = class {
22149
22239
  if (tokenIndex === 0) {
22150
22240
  return this.getCommandNames(this.registry.processors, token);
22151
22241
  }
22152
- const mainCommand = tokens[0];
22153
- const processor = this.registry.findProcessor(mainCommand, []);
22154
- if (!processor?.processors?.length) {
22242
+ const path = resolveCompletionPath(
22243
+ tokens,
22244
+ tokenIndex,
22245
+ this.registry.processors,
22246
+ token
22247
+ );
22248
+ if (path.isFlagValue || !path.subCommands) {
22155
22249
  return [];
22156
22250
  }
22157
- let current = processor;
22158
- for (let i = 1; i < tokenIndex; i++) {
22159
- const sub = current.processors?.find(
22160
- (p) => p.command === tokens[i]
22161
- );
22162
- if (!sub?.processors?.length) {
22163
- return [];
22164
- }
22165
- current = sub;
22166
- }
22167
- return this.getCommandNames(current.processors ?? [], token);
22251
+ return this.getCommandNames(path.subCommands, token);
22168
22252
  }
22169
22253
  getCommandNames(processors, prefix) {
22170
22254
  const names = [];
@@ -22186,24 +22270,24 @@ var CliParameterCompletionProvider = class {
22186
22270
  this.priority = 200;
22187
22271
  }
22188
22272
  getCompletions(context2) {
22189
- const { tokens, token } = context2;
22273
+ const { tokens, tokenIndex, token } = context2;
22190
22274
  if (!token.startsWith("-")) {
22191
22275
  return [];
22192
22276
  }
22193
22277
  if (tokens.length === 0) {
22194
22278
  return [];
22195
22279
  }
22196
- const mainCommand = tokens[0];
22197
- const chainCommands = tokens.slice(1).filter((t) => !t.startsWith("-"));
22198
- const processor = this.registry.findProcessorInCollection(
22199
- mainCommand,
22200
- chainCommands,
22201
- this.registry.processors
22280
+ const path = resolveCompletionPath(
22281
+ tokens,
22282
+ tokenIndex,
22283
+ this.registry.processors,
22284
+ token
22202
22285
  );
22286
+ const seen = /* @__PURE__ */ new Set();
22203
22287
  const allParameters = [
22204
- ...processor?.parameters ?? [],
22288
+ ...path.descriptors,
22205
22289
  ...this.executor.getGlobalParameters()
22206
- ];
22290
+ ].filter((p) => !seen.has(p.name) && !!seen.add(p.name));
22207
22291
  if (allParameters.length === 0) {
22208
22292
  return [];
22209
22293
  }