termkit 2.3.1 → 2.4.0

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/dist/index.mjs CHANGED
@@ -131,6 +131,8 @@ function findCommand(array, commands) {
131
131
  var RESET = "\x1B[0m";
132
132
  var SHOW_CURSOR = "\x1B[?25h";
133
133
  var HIDE_CURSOR = "\x1B[?25l";
134
+ var DISABLE_WRAP = "\x1B[?7l";
135
+ var ENABLE_WRAP = "\x1B[?7h";
134
136
  var BOLD = "\x1B[1m";
135
137
  var FAINT = "\x1B[2m";
136
138
  var GREEN = "\x1B[32m";
@@ -497,15 +499,22 @@ var Select = class {
497
499
  if (!process.stdin.isTTY || !process.stdout.isTTY) throw new Error("Select requires an interactive terminal");
498
500
  let selectedIndex = 0;
499
501
  let viewportOffset = 0;
502
+ let visibleStart = 0;
500
503
  let searchQuery = "";
501
504
  let lastDrawnLines = 0;
502
505
  const skipItem = { label: this.skipLabel };
506
+ const computeMaxHeight = () => {
507
+ const termRows = process.stdout.rows ?? 24;
508
+ const reserved = 1 + (this.searchEnabled ? 1 : 0);
509
+ const fit = Math.max(1, termRows - reserved - 1);
510
+ return this.maxHeight ? Math.min(this.maxHeight, fit) : fit;
511
+ };
503
512
  const getFiltered = () => {
504
513
  if (!this.searchEnabled || searchQuery === "") return items;
505
514
  const q = searchQuery.toLowerCase();
506
515
  return items.filter((item) => item.label.toLowerCase().includes(q) || (item.description?.toLowerCase().includes(q) ?? false));
507
516
  };
508
- process.stdout.write(HIDE_CURSOR);
517
+ process.stdout.write(HIDE_CURSOR + DISABLE_WRAP);
509
518
  const glyph = this.promptGlyph ? `${colorText(this.promptColor, this.promptGlyph)} ` : "";
510
519
  const indent = " ".repeat(this.promptGlyph ? stringLength(this.promptGlyph) + 1 : 0);
511
520
  process.stdout.write(`${glyph}${prompt}
@@ -514,13 +523,17 @@ var Select = class {
514
523
  const filtered = getFiltered();
515
524
  const allItems = [...filtered, skipItem];
516
525
  if (selectedIndex >= allItems.length) selectedIndex = allItems.length - 1;
517
- if (this.maxHeight) {
526
+ const maxHeight = computeMaxHeight();
527
+ const useViewport = allItems.length > maxHeight;
528
+ if (useViewport) {
518
529
  if (selectedIndex < viewportOffset) viewportOffset = selectedIndex;
519
- else if (selectedIndex >= viewportOffset + this.maxHeight) viewportOffset = selectedIndex - this.maxHeight + 1;
520
- viewportOffset = Math.max(0, Math.min(viewportOffset, Math.max(0, allItems.length - this.maxHeight)));
530
+ else if (selectedIndex >= viewportOffset + maxHeight) viewportOffset = selectedIndex - maxHeight + 1;
531
+ viewportOffset = Math.max(0, Math.min(viewportOffset, Math.max(0, allItems.length - maxHeight)));
532
+ } else {
533
+ viewportOffset = 0;
521
534
  }
522
- const visibleStart = this.maxHeight ? viewportOffset : 0;
523
- const visibleEnd = this.maxHeight ? Math.min(allItems.length, viewportOffset + this.maxHeight) : allItems.length;
535
+ visibleStart = useViewport ? viewportOffset : 0;
536
+ const visibleEnd = useViewport ? Math.min(allItems.length, viewportOffset + maxHeight) : allItems.length;
524
537
  if (redraw) {
525
538
  if (lastDrawnLines > 0) process.stdout.write(CURSOR_UP(lastDrawnLines));
526
539
  process.stdout.write("\r\x1B[0J");
@@ -536,8 +549,7 @@ var Select = class {
536
549
  const item = allItems[i];
537
550
  const isSelected = i === selectedIndex;
538
551
  const isSkip = i === filtered.length;
539
- const relativeNum = i - visibleStart + 1;
540
- const numStr = isSkip ? "0." : `${relativeNum}.`;
552
+ const numStr = isSkip ? "0." : `${i + 1}.`;
541
553
  const desc = item.description ? ` ${colorText(this.descriptionColor, `\u2014 ${item.description}`)}` : "";
542
554
  let marker, tail;
543
555
  if (isSelected && pulse) {
@@ -564,7 +576,7 @@ var Select = class {
564
576
  process.stdin.setRawMode(false);
565
577
  process.stdin.pause();
566
578
  process.stdin.removeListener("data", onKey);
567
- process.stdout.write(SHOW_CURSOR);
579
+ process.stdout.write(ENABLE_WRAP + SHOW_CURSOR);
568
580
  });
569
581
  const cleanup = () => {
570
582
  deregisterCleanup();
@@ -575,7 +587,7 @@ var Select = class {
575
587
  process.stdin.setRawMode(false);
576
588
  process.stdin.pause();
577
589
  process.stdin.removeListener("data", onKey);
578
- process.stdout.write(SHOW_CURSOR);
590
+ process.stdout.write(ENABLE_WRAP + SHOW_CURSOR);
579
591
  };
580
592
  if (this._parsedColors.length >= 2) {
581
593
  timer = setInterval(() => {
@@ -618,8 +630,7 @@ var Select = class {
618
630
  } else {
619
631
  const n = parseInt(str);
620
632
  if (!isNaN(n) && n >= 0 && n <= Math.min(items.length, 9)) {
621
- const visibleStart = this.maxHeight ? viewportOffset : 0;
622
- selectedIndex = n === 0 ? allItems.length - 1 : visibleStart + n - 1;
633
+ selectedIndex = n === 0 ? allItems.length - 1 : n - 1;
623
634
  selectedIndex = Math.max(0, Math.min(selectedIndex, allItems.length - 1));
624
635
  renderList(true);
625
636
  }
@@ -800,7 +811,7 @@ var Command = class {
800
811
  constructor(data) {
801
812
  this.actionFunction = null;
802
813
  this.commandsArray = [];
803
- this.commandStrings = ["help"];
814
+ this.commandStrings = ["help", "version"];
804
815
  this.info = null;
805
816
  this.middlewaresArray = [];
806
817
  this.name = null;
@@ -870,6 +881,9 @@ var Command = class {
870
881
  const recursive = source?.includes("-r") === true || source?.includes("--recursive") === true;
871
882
  this.printHelp(this.name ?? "Program", recursive);
872
883
  }
884
+ printVersion() {
885
+ console.log(this.versionString ?? "");
886
+ }
873
887
  printHelp(fullName, recursive) {
874
888
  const table = [];
875
889
  let program = fullName;
@@ -929,29 +943,32 @@ var Command = class {
929
943
  }
930
944
  }
931
945
  }
932
- async parse(input2) {
933
- const array = [...input2];
934
- array.splice(0, 2);
946
+ async _execute(tokens) {
947
+ const array = [...tokens];
935
948
  let command = this;
936
949
  const options = { _source: Array.from(array) };
950
+ if (this.versionString && (array.includes("--version") || array.includes("-V"))) {
951
+ return this.printVersion();
952
+ }
937
953
  const ddIdx = array.indexOf("--");
938
954
  if (ddIdx !== -1) {
939
955
  options._ = array.splice(ddIdx + 1);
940
956
  array.splice(ddIdx, 1);
941
957
  }
942
958
  while (array.length) {
943
- if (!array.includes("help")) {
959
+ if (!array.includes("help") && !array.includes("version")) {
944
960
  Object.assign(options, await findOptions(array, command));
945
961
  const cmdVars = await findCommandVariables(array, command);
946
962
  if (cmdVars) Object.assign(options, cmdVars);
947
963
  Object.assign(options, await findOptions(array, command));
948
964
  }
949
965
  if (array.length) {
950
- if (!array.includes("help")) {
966
+ if (!array.includes("help") && !array.includes("version")) {
951
967
  for (const mw of command.middlewaresArray) await mw(options);
952
968
  }
953
969
  const next = findCommand(array, command.commandsArray);
954
970
  if (!next && array[0] === "help") return command.help(options._source);
971
+ if (!next && array[0] === "version") return this.printVersion();
955
972
  if (!next) throw new SyntaxError(`Unknown command: ${array[0]}`);
956
973
  const name = command.name ?? "_base";
957
974
  if (!options._parents) options._parents = {};
@@ -975,11 +992,226 @@ var Command = class {
975
992
  }
976
993
  for (const mw of command.middlewaresArray) await mw(options);
977
994
  if (command.actionFunction) return command.actionFunction(options);
978
- if (options._source.length === 2) return command.help(options._source);
979
- throw new Error(`No action for command: ${command.name ?? "_base"}`);
995
+ return command.help(options._source);
996
+ }
997
+ async parse(input2) {
998
+ return this._execute(input2.slice(2));
980
999
  }
981
1000
  };
982
1001
 
1002
+ // src/models/Shell.ts
1003
+ import cosmetic2 from "cosmetic";
1004
+ import * as readline from "readline";
1005
+ var Shell = class {
1006
+ constructor(root, opts = {}) {
1007
+ this.rl = null;
1008
+ this.root = root;
1009
+ this.opts = {
1010
+ mode: opts.mode ?? "drill",
1011
+ prompt: opts.prompt ?? root.name ?? "shell",
1012
+ promptColor: opts.promptColor ?? "",
1013
+ banner: opts.banner ?? "",
1014
+ exitCommands: opts.exitCommands ?? ["exit", "quit"],
1015
+ historySize: opts.historySize ?? 100
1016
+ };
1017
+ }
1018
+ async run() {
1019
+ this.rl = readline.createInterface({
1020
+ input: process.stdin,
1021
+ output: process.stdout,
1022
+ terminal: true,
1023
+ historySize: this.opts.historySize,
1024
+ completer: this.opts.mode === "free" ? makeCompleter(this.root) : void 0
1025
+ });
1026
+ if (this.opts.banner) console.log(this.opts.banner);
1027
+ try {
1028
+ if (this.opts.mode === "free") {
1029
+ await this.freeLoop();
1030
+ } else {
1031
+ await this.drillLoop();
1032
+ }
1033
+ } finally {
1034
+ this.rl.close();
1035
+ }
1036
+ }
1037
+ // ── Drill mode ────────────────────────────────────────────────────────
1038
+ async drillLoop() {
1039
+ while (true) {
1040
+ const exited = await this.drillFrom(this.root, [this.root.name ?? "shell"]);
1041
+ if (exited) return;
1042
+ }
1043
+ }
1044
+ async drillFrom(cmd, breadcrumb) {
1045
+ while (true) {
1046
+ const token = await this.promptDrill(cmd, breadcrumb);
1047
+ if (token === null) {
1048
+ return breadcrumb.length === 1;
1049
+ }
1050
+ if (this.opts.exitCommands.includes(token)) process.exit(0);
1051
+ if (token === "..") return false;
1052
+ if (token === "help") {
1053
+ cmd.help();
1054
+ continue;
1055
+ }
1056
+ const sub = cmd.commandsArray.find((c) => c.name === token);
1057
+ if (!sub) {
1058
+ process.stderr.write(`Unknown command: ${token}
1059
+ `);
1060
+ continue;
1061
+ }
1062
+ if (sub.commandsArray.length > 0) {
1063
+ const exited = await this.drillFrom(sub, [...breadcrumb, sub.name ?? ""]);
1064
+ if (exited) return true;
1065
+ continue;
1066
+ }
1067
+ const vars = await this.gatherVariables(sub);
1068
+ const tokens = buildTokens(sub, vars);
1069
+ try {
1070
+ await sub._execute(tokens);
1071
+ } catch (err) {
1072
+ process.stderr.write(`${err instanceof Error ? err.message : err}
1073
+ `);
1074
+ }
1075
+ return false;
1076
+ }
1077
+ }
1078
+ async promptDrill(cmd, breadcrumb) {
1079
+ const subs = cmd.commandsArray.map((c) => c.name ?? "").filter(Boolean);
1080
+ const label = this.colorize(breadcrumb.join(" "));
1081
+ const choices = [...subs, "help"].join(", ");
1082
+ process.stdout.write(`
1083
+ ${label} ${choices}
1084
+ `);
1085
+ return new Promise((resolve) => {
1086
+ let resolved = false;
1087
+ const done = (val) => {
1088
+ if (!resolved) {
1089
+ resolved = true;
1090
+ resolve(val);
1091
+ }
1092
+ };
1093
+ this.rl.question("> ", (answer) => done(answer.trim() || null));
1094
+ this.rl.once("close", () => done(null));
1095
+ });
1096
+ }
1097
+ async gatherVariables(cmd) {
1098
+ const result = {};
1099
+ if (!cmd.variables) return result;
1100
+ for (const v of cmd.variables) {
1101
+ const name = v.name ?? "value";
1102
+ const hint = v.hint ? ` ${v.hint}` : "";
1103
+ while (true) {
1104
+ const answer = await new Promise((resolve) => {
1105
+ let resolved = false;
1106
+ const done = (val) => {
1107
+ if (!resolved) {
1108
+ resolved = true;
1109
+ resolve(val);
1110
+ }
1111
+ };
1112
+ this.rl.question(` ${name}${hint}: `, (ans) => done(ans.trim() || null));
1113
+ this.rl.once("close", () => done(null));
1114
+ });
1115
+ const value = answer ?? v.default ?? null;
1116
+ if (!value && v.required) {
1117
+ process.stderr.write(` ${name} is required
1118
+ `);
1119
+ continue;
1120
+ }
1121
+ if (value) {
1122
+ if (v.type === "enum" && v.enum && !v.enum.includes(value)) {
1123
+ process.stderr.write(` Must be one of: ${v.enum.join(", ")}
1124
+ `);
1125
+ continue;
1126
+ }
1127
+ result[name] = value;
1128
+ }
1129
+ break;
1130
+ }
1131
+ }
1132
+ return result;
1133
+ }
1134
+ // ── Free mode ─────────────────────────────────────────────────────────
1135
+ async freeLoop() {
1136
+ const prompt = `${this.colorize(this.opts.prompt)} > `;
1137
+ this.rl.setPrompt(prompt);
1138
+ this.rl.prompt();
1139
+ for await (const line of this.rl) {
1140
+ const trimmed = line.trim();
1141
+ if (!trimmed) {
1142
+ this.rl.prompt();
1143
+ continue;
1144
+ }
1145
+ if (this.opts.exitCommands.includes(trimmed)) break;
1146
+ const tokens = tokenize(trimmed);
1147
+ try {
1148
+ await this.root._execute(tokens);
1149
+ } catch (err) {
1150
+ process.stderr.write(`${err instanceof Error ? err.message : err}
1151
+ `);
1152
+ }
1153
+ this.rl.prompt();
1154
+ }
1155
+ }
1156
+ // ── Helpers ───────────────────────────────────────────────────────────
1157
+ colorize(text) {
1158
+ const c = this.opts.promptColor;
1159
+ if (!c || !process.stdout.isTTY) return text;
1160
+ try {
1161
+ if (c.startsWith("#")) return cosmetic2.hex(c).encoder(text);
1162
+ if (/^\d+$/.test(c)) return cosmetic2.xterm(Number(c)).encoder(text);
1163
+ const style = cosmetic2[c];
1164
+ if (style && typeof style.encoder === "function") return style.encoder(text);
1165
+ } catch {
1166
+ }
1167
+ return text;
1168
+ }
1169
+ };
1170
+ function tokenize(line) {
1171
+ const tokens = [];
1172
+ let current = "";
1173
+ let inQuote = null;
1174
+ for (const ch of line) {
1175
+ if (inQuote) {
1176
+ if (ch === inQuote) {
1177
+ inQuote = null;
1178
+ } else {
1179
+ current += ch;
1180
+ }
1181
+ } else if (ch === '"' || ch === "'") {
1182
+ inQuote = ch;
1183
+ } else if (ch === " " || ch === " ") {
1184
+ if (current) {
1185
+ tokens.push(current);
1186
+ current = "";
1187
+ }
1188
+ } else {
1189
+ current += ch;
1190
+ }
1191
+ }
1192
+ if (current) tokens.push(current);
1193
+ return tokens;
1194
+ }
1195
+ function buildTokens(cmd, vars) {
1196
+ if (!cmd.variables) return [];
1197
+ return cmd.variables.map((v) => vars[v.name ?? ""]).filter((v) => v !== void 0 && v !== "");
1198
+ }
1199
+ function makeCompleter(root) {
1200
+ return (line) => {
1201
+ const tokens = tokenize(line);
1202
+ let cmd = root;
1203
+ for (const token of tokens.slice(0, -1)) {
1204
+ const sub = cmd.commandsArray.find((c) => c.name === token);
1205
+ if (!sub) break;
1206
+ cmd = sub;
1207
+ }
1208
+ const partial = tokens[tokens.length - 1] ?? "";
1209
+ const names = [...cmd.commandsArray.map((c) => c.name ?? "").filter(Boolean), "help"];
1210
+ const hits = names.filter((n) => n.startsWith(partial));
1211
+ return [hits.length ? hits : names, partial];
1212
+ };
1213
+ }
1214
+
983
1215
  // src/models/Bar.ts
984
1216
  var _Bar = class _Bar {
985
1217
  constructor(text, options) {
@@ -2048,7 +2280,7 @@ var MultiSelect = class {
2048
2280
  const checked = /* @__PURE__ */ new Set();
2049
2281
  let error = null;
2050
2282
  let lastDrawnLines = 0;
2051
- process.stdout.write(HIDE_CURSOR);
2283
+ process.stdout.write(HIDE_CURSOR + DISABLE_WRAP);
2052
2284
  const glyph = this.promptGlyph ? `${colorText(this.promptColor, this.promptGlyph)} ` : "";
2053
2285
  const indent = " ".repeat(this.promptGlyph ? stringLength(this.promptGlyph) + 1 : 0);
2054
2286
  process.stdout.write(`${glyph}${prompt}
@@ -2058,16 +2290,26 @@ var MultiSelect = class {
2058
2290
  const q = searchQuery.toLowerCase();
2059
2291
  return items.map((item, i) => ({ item, originalIndex: i })).filter(({ item }) => item.label.toLowerCase().includes(q) || (item.description?.toLowerCase().includes(q) ?? false));
2060
2292
  };
2293
+ const computeMaxHeight = () => {
2294
+ const termRows = process.stdout.rows ?? 24;
2295
+ const reserved = 1 + (this.searchEnabled ? 1 : 0) + 1 + 1;
2296
+ const fit = Math.max(1, termRows - reserved - 1);
2297
+ return this.maxHeight ? Math.min(this.maxHeight, fit) : fit;
2298
+ };
2061
2299
  const renderList = (redraw) => {
2062
2300
  const filtered = getFiltered();
2063
2301
  if (cursor >= filtered.length) cursor = Math.max(0, filtered.length - 1);
2064
- if (this.maxHeight) {
2302
+ const maxHeight = computeMaxHeight();
2303
+ const useViewport = filtered.length > maxHeight;
2304
+ if (useViewport) {
2065
2305
  if (cursor < viewportOffset) viewportOffset = cursor;
2066
- else if (cursor >= viewportOffset + this.maxHeight) viewportOffset = cursor - this.maxHeight + 1;
2067
- viewportOffset = Math.max(0, Math.min(viewportOffset, Math.max(0, filtered.length - this.maxHeight)));
2306
+ else if (cursor >= viewportOffset + maxHeight) viewportOffset = cursor - maxHeight + 1;
2307
+ viewportOffset = Math.max(0, Math.min(viewportOffset, Math.max(0, filtered.length - maxHeight)));
2308
+ } else {
2309
+ viewportOffset = 0;
2068
2310
  }
2069
- const visibleStart = this.maxHeight ? viewportOffset : 0;
2070
- const visibleEnd = this.maxHeight ? Math.min(filtered.length, viewportOffset + this.maxHeight) : filtered.length;
2311
+ const visibleStart = useViewport ? viewportOffset : 0;
2312
+ const visibleEnd = useViewport ? Math.min(filtered.length, viewportOffset + maxHeight) : filtered.length;
2071
2313
  if (redraw) {
2072
2314
  if (lastDrawnLines > 0) process.stdout.write(CURSOR_UP3(lastDrawnLines));
2073
2315
  process.stdout.write("\r\x1B[0J");
@@ -2083,14 +2325,15 @@ var MultiSelect = class {
2083
2325
  const { item, originalIndex } = filtered[vi];
2084
2326
  const isCursor = vi === cursor;
2085
2327
  const isChecked = checked.has(originalIndex);
2328
+ const numStr = `${vi + 1}.`;
2086
2329
  const desc = item.description ? ` ${colorText(this.descriptionColor, `\u2014 ${item.description}`)}` : "";
2087
2330
  const checkMark = isChecked ? pulse ? `${pulse}${this.checkedPrefix}${RESET}` : colorText(this.promptColor, this.checkedPrefix) : this.uncheckedPrefix;
2088
2331
  const label = isCursor ? pulse ? `${pulse}${item.label}${RESET}` : colorText(this.promptColor, item.label) : item.label;
2089
- process.stdout.write(`\r${indent}${checkMark} ${label}${desc}
2332
+ process.stdout.write(`\r${indent}${numStr} ${checkMark} ${label}${desc}
2090
2333
  `);
2091
2334
  lastDrawnLines++;
2092
2335
  }
2093
- const hintContent = `\u2191\u2193 move space/tab toggle \u2190\u2192 deselect/select${this.searchEnabled ? " type to filter" : " a all"} enter confirm`;
2336
+ const hintContent = `\u2191\u2193 move space/tab toggle \u2190\u2192 deselect/select${this.searchEnabled ? " type to filter" : " 1-9 jump a all"} enter confirm`;
2094
2337
  const maxHintCols = Math.max(10, (process.stdout.columns ?? 80) - stringLength(indent) - 1);
2095
2338
  const hint = stringLength(hintContent) > maxHintCols ? hintContent.slice(0, maxHintCols) : hintContent;
2096
2339
  process.stdout.write(`\r${indent}${DIM2}${hint}${RESET}
@@ -2113,7 +2356,7 @@ var MultiSelect = class {
2113
2356
  process.stdin.setRawMode(false);
2114
2357
  process.stdin.pause();
2115
2358
  process.stdin.removeListener("data", onKey);
2116
- process.stdout.write(SHOW_CURSOR);
2359
+ process.stdout.write(ENABLE_WRAP + SHOW_CURSOR);
2117
2360
  });
2118
2361
  const cleanup = (result) => {
2119
2362
  deregisterCleanup();
@@ -2123,6 +2366,7 @@ var MultiSelect = class {
2123
2366
  }
2124
2367
  if (lastDrawnLines > 0) process.stdout.write(CURSOR_UP3(lastDrawnLines));
2125
2368
  process.stdout.write("\x1B[0J");
2369
+ process.stdout.write(ENABLE_WRAP);
2126
2370
  const bulletWidth = stringLength(this.checkedPrefix) + 1;
2127
2371
  for (let i = 0; i < items.length; i++) {
2128
2372
  const item = items[i];
@@ -2134,7 +2378,7 @@ var MultiSelect = class {
2134
2378
  process.stdin.setRawMode(false);
2135
2379
  process.stdin.pause();
2136
2380
  process.stdin.removeListener("data", onKey);
2137
- process.stdout.write(SHOW_CURSOR);
2381
+ process.stdout.write(ENABLE_WRAP + SHOW_CURSOR);
2138
2382
  resolve(result);
2139
2383
  };
2140
2384
  if (this._parsedColors.length >= 2) {
@@ -2223,7 +2467,7 @@ var MultiSelect = class {
2223
2467
  process.stdin.setRawMode(false);
2224
2468
  process.stdin.pause();
2225
2469
  process.stdin.removeListener("data", onKey);
2226
- process.stdout.write(SHOW_CURSOR);
2470
+ process.stdout.write(ENABLE_WRAP + SHOW_CURSOR);
2227
2471
  process.exit(130);
2228
2472
  } else if (this.searchEnabled) {
2229
2473
  if (str === "\x7F" || str === "\b") {
@@ -2243,7 +2487,7 @@ var MultiSelect = class {
2243
2487
  const n = parseInt(str);
2244
2488
  if (!isNaN(n) && n >= 1 && n <= Math.min(filtered.length, 9)) {
2245
2489
  error = null;
2246
- cursor = viewportOffset + n - 1;
2490
+ cursor = n - 1;
2247
2491
  renderList(true);
2248
2492
  }
2249
2493
  }
@@ -2617,7 +2861,7 @@ _Spinner.FRAMES = {
2617
2861
  var Spinner = _Spinner;
2618
2862
 
2619
2863
  // src/models/Table.ts
2620
- import cosmetic2 from "cosmetic";
2864
+ import cosmetic3 from "cosmetic";
2621
2865
 
2622
2866
  // src/utils/padSides.ts
2623
2867
  var padSides = (string, padding) => {
@@ -2695,7 +2939,7 @@ var Table = class {
2695
2939
  header += pad(column.title, column.padding + this.margin);
2696
2940
  if (i < keys.length - 1) header += this.separator;
2697
2941
  }
2698
- const styled = typeof config.color === "number" ? cosmetic2.xterm(config.color) : config.color.startsWith("#") ? cosmetic2.hex(config.color) : cosmetic2[config.color];
2942
+ const styled = typeof config.color === "number" ? cosmetic3.xterm(config.color) : config.color.startsWith("#") ? cosmetic3.hex(config.color) : cosmetic3[config.color];
2699
2943
  this.string += `${styled.underline.encoder(header)}
2700
2944
  `;
2701
2945
  for (const [ri, row] of this.rows.entries()) {
@@ -2772,7 +3016,7 @@ var commandDefaults = {};
2772
3016
  var Program = {
2773
3017
  command: (name, variables, info) => {
2774
3018
  const cmd = new Command(Object.assign({ name, variables, info }, commandDefaults));
2775
- if (!base) base = cmd;
3019
+ base = cmd;
2776
3020
  return cmd;
2777
3021
  },
2778
3022
  option: (short, long, variables, info) => new Option({ short, long, variables, info }),
@@ -2795,6 +3039,10 @@ var Program = {
2795
3039
  },
2796
3040
  setDefaults: (data) => {
2797
3041
  commandDefaults = data;
3042
+ },
3043
+ shell: async (options) => {
3044
+ if (!base) throw new Error("No command defined");
3045
+ return new Shell(base, options).run();
2798
3046
  }
2799
3047
  };
2800
3048
  export {
@@ -2811,6 +3059,7 @@ export {
2811
3059
  Program,
2812
3060
  Scrollbox,
2813
3061
  Select,
3062
+ Shell,
2814
3063
  Spinner,
2815
3064
  Table,
2816
3065
  TermKit,
@@ -31,7 +31,9 @@ export declare class Command {
31
31
  version(v: string): this;
32
32
  private buildInfo;
33
33
  help(source?: string[]): void;
34
+ printVersion(): void;
34
35
  private printHelp;
36
+ _execute(tokens: string[]): Promise<unknown>;
35
37
  parse(input: string[]): Promise<unknown>;
36
38
  }
37
39
  export {};
@@ -1 +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,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAEzH"}
@@ -0,0 +1,23 @@
1
+ import type { Command } from '@/models/Command';
2
+ export interface ShellOptions {
3
+ mode?: 'drill' | 'free';
4
+ prompt?: string;
5
+ promptColor?: string;
6
+ banner?: string;
7
+ exitCommands?: string[];
8
+ historySize?: number;
9
+ }
10
+ export declare class Shell {
11
+ private root;
12
+ private opts;
13
+ private rl;
14
+ constructor(root: Command, opts?: ShellOptions);
15
+ run(): Promise<void>;
16
+ private drillLoop;
17
+ private drillFrom;
18
+ private promptDrill;
19
+ private gatherVariables;
20
+ private freeLoop;
21
+ private colorize;
22
+ }
23
+ //# sourceMappingURL=Shell.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Shell.d.ts","sourceRoot":"","sources":["../../src/models/Shell.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAE/C,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;IACvB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;IACvB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAID,qBAAa,KAAK;IAChB,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,IAAI,CAAc;IAC1B,OAAO,CAAC,EAAE,CAAkC;gBAEhC,IAAI,EAAE,OAAO,EAAE,IAAI,GAAE,YAAiB;IAY5C,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;YAwBZ,SAAS;YAOT,SAAS;YAuCT,WAAW;YAmBX,eAAe;YA4Cf,QAAQ;IAwBtB,OAAO,CAAC,QAAQ;CAajB"}
@@ -1,6 +1,8 @@
1
1
  export declare const RESET = "\u001B[0m";
2
2
  export declare const SHOW_CURSOR = "\u001B[?25h";
3
3
  export declare const HIDE_CURSOR = "\u001B[?25l";
4
+ export declare const DISABLE_WRAP = "\u001B[?7l";
5
+ export declare const ENABLE_WRAP = "\u001B[?7h";
4
6
  export declare const BOLD = "\u001B[1m";
5
7
  export declare const FAINT = "\u001B[2m";
6
8
  export declare const GREEN = "\u001B[32m";
@@ -1 +1 @@
1
- {"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../src/utils/color.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,KAAK,cAAY,CAAA;AAC9B,eAAO,MAAM,WAAW,gBAAc,CAAA;AACtC,eAAO,MAAM,WAAW,gBAAc,CAAA;AACtC,eAAO,MAAM,IAAI,cAAY,CAAA;AAC7B,eAAO,MAAM,KAAK,cAAY,CAAA;AAC9B,eAAO,MAAM,KAAK,eAAa,CAAA;AAC/B,eAAO,MAAM,GAAG,eAAa,CAAA;AAC7B,eAAO,MAAM,MAAM,eAAa,CAAA;AAChC,eAAO,MAAM,IAAI,eAAa,CAAA;AAC9B,eAAO,MAAM,OAAO,eAAa,CAAA;AACjC,eAAO,MAAM,IAAI,eAAa,CAAA;AAC9B,eAAO,MAAM,GAAG,OAAO,CAAA;AACvB,eAAO,MAAM,aAAa,MAAM,CAAA;AAQhC,MAAM,WAAW,QAAQ;IACvB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,CAG9C;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,GAAG,QAAQ,CAMvE;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,QAAQ,CAMxE;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,EAAE,GA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+ "version": "2.4.0",
4
4
  "description": "Node.js terminal toolkit with CLI commands, progress bars, charts, tables, styled markup, prompts, and text utilities",
5
5
  "keywords": [
6
6
  "animation",
@@ -65,6 +65,7 @@
65
65
  "demo:multiselect": "node demos/multiselect.js",
66
66
  "demo:program": "node demos/program.js",
67
67
  "demo:select": "node demos/select.js",
68
+ "demo:shell": "node demos/shell.js",
68
69
  "demo:spinner": "node demos/spinner.js",
69
70
  "demo:table": "node demos/table.js",
70
71
  "demo:text": "node demos/text.js",
@@ -81,7 +82,7 @@
81
82
  "preversion": "npm run validate"
82
83
  },
83
84
  "dependencies": {
84
- "cosmetic": "^1.4.1"
85
+ "cosmetic": "^1.4.2"
85
86
  },
86
87
  "devDependencies": {
87
88
  "@types/jest": "^30.0.0",