termkit 2.3.1 → 2.4.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/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,9 +576,9 @@ 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
- const cleanup = () => {
581
+ const cleanup = (selectedLabel) => {
570
582
  deregisterCleanup();
571
583
  if (timer) {
572
584
  clearInterval(timer);
@@ -575,6 +587,11 @@ var Select = class {
575
587
  process.stdin.setRawMode(false);
576
588
  process.stdin.pause();
577
589
  process.stdin.removeListener("data", onKey);
590
+ process.stdout.write(CURSOR_UP(lastDrawnLines + 1));
591
+ process.stdout.write("\r\x1B[0J");
592
+ process.stdout.write(ENABLE_WRAP);
593
+ process.stdout.write(`${glyph}${prompt}: ${selectedLabel ?? this.skipLabel}
594
+ `);
578
595
  process.stdout.write(SHOW_CURSOR);
579
596
  };
580
597
  if (this._parsedColors.length >= 2) {
@@ -597,10 +614,19 @@ var Select = class {
597
614
  selectedIndex = (selectedIndex + 1) % allItems.length;
598
615
  renderList(true);
599
616
  } else if (str === "\r" || str === "\n") {
600
- cleanup();
601
- resolve(selectedIndex === filtered.length ? null : filtered[selectedIndex] ?? null);
617
+ const result = selectedIndex === filtered.length ? null : filtered[selectedIndex] ?? null;
618
+ cleanup(result?.label ?? null);
619
+ resolve(result);
602
620
  } else if (str === "") {
603
- cleanup();
621
+ deregisterCleanup();
622
+ if (timer) {
623
+ clearInterval(timer);
624
+ timer = null;
625
+ }
626
+ process.stdin.setRawMode(false);
627
+ process.stdin.pause();
628
+ process.stdin.removeListener("data", onKey);
629
+ process.stdout.write(ENABLE_WRAP + SHOW_CURSOR);
604
630
  process.exit(130);
605
631
  } else if (this.searchEnabled) {
606
632
  if (str === "\x7F" || str === "\b") {
@@ -618,8 +644,7 @@ var Select = class {
618
644
  } else {
619
645
  const n = parseInt(str);
620
646
  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;
647
+ selectedIndex = n === 0 ? allItems.length - 1 : n - 1;
623
648
  selectedIndex = Math.max(0, Math.min(selectedIndex, allItems.length - 1));
624
649
  renderList(true);
625
650
  }
@@ -800,7 +825,7 @@ var Command = class {
800
825
  constructor(data) {
801
826
  this.actionFunction = null;
802
827
  this.commandsArray = [];
803
- this.commandStrings = ["help"];
828
+ this.commandStrings = ["help", "version"];
804
829
  this.info = null;
805
830
  this.middlewaresArray = [];
806
831
  this.name = null;
@@ -870,6 +895,9 @@ var Command = class {
870
895
  const recursive = source?.includes("-r") === true || source?.includes("--recursive") === true;
871
896
  this.printHelp(this.name ?? "Program", recursive);
872
897
  }
898
+ printVersion() {
899
+ console.log(this.versionString ?? "");
900
+ }
873
901
  printHelp(fullName, recursive) {
874
902
  const table = [];
875
903
  let program = fullName;
@@ -929,29 +957,32 @@ var Command = class {
929
957
  }
930
958
  }
931
959
  }
932
- async parse(input2) {
933
- const array = [...input2];
934
- array.splice(0, 2);
960
+ async _execute(tokens) {
961
+ const array = [...tokens];
935
962
  let command = this;
936
963
  const options = { _source: Array.from(array) };
964
+ if (this.versionString && (array.includes("--version") || array.includes("-V"))) {
965
+ return this.printVersion();
966
+ }
937
967
  const ddIdx = array.indexOf("--");
938
968
  if (ddIdx !== -1) {
939
969
  options._ = array.splice(ddIdx + 1);
940
970
  array.splice(ddIdx, 1);
941
971
  }
942
972
  while (array.length) {
943
- if (!array.includes("help")) {
973
+ if (!array.includes("help") && !array.includes("version")) {
944
974
  Object.assign(options, await findOptions(array, command));
945
975
  const cmdVars = await findCommandVariables(array, command);
946
976
  if (cmdVars) Object.assign(options, cmdVars);
947
977
  Object.assign(options, await findOptions(array, command));
948
978
  }
949
979
  if (array.length) {
950
- if (!array.includes("help")) {
980
+ if (!array.includes("help") && !array.includes("version")) {
951
981
  for (const mw of command.middlewaresArray) await mw(options);
952
982
  }
953
983
  const next = findCommand(array, command.commandsArray);
954
984
  if (!next && array[0] === "help") return command.help(options._source);
985
+ if (!next && array[0] === "version") return this.printVersion();
955
986
  if (!next) throw new SyntaxError(`Unknown command: ${array[0]}`);
956
987
  const name = command.name ?? "_base";
957
988
  if (!options._parents) options._parents = {};
@@ -975,10 +1006,225 @@ var Command = class {
975
1006
  }
976
1007
  for (const mw of command.middlewaresArray) await mw(options);
977
1008
  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"}`);
1009
+ return command.help(options._source);
1010
+ }
1011
+ async parse(input2) {
1012
+ return this._execute(input2.slice(2));
1013
+ }
1014
+ };
1015
+
1016
+ // src/models/Shell.ts
1017
+ import cosmetic2 from "cosmetic";
1018
+ import * as readline from "readline";
1019
+ var Shell = class {
1020
+ constructor(root, opts = {}) {
1021
+ this.rl = null;
1022
+ this.root = root;
1023
+ this.opts = {
1024
+ mode: opts.mode ?? "drill",
1025
+ prompt: opts.prompt ?? root.name ?? "shell",
1026
+ promptColor: opts.promptColor ?? "",
1027
+ banner: opts.banner ?? "",
1028
+ exitCommands: opts.exitCommands ?? ["exit", "quit"],
1029
+ historySize: opts.historySize ?? 100
1030
+ };
1031
+ }
1032
+ async run() {
1033
+ this.rl = readline.createInterface({
1034
+ input: process.stdin,
1035
+ output: process.stdout,
1036
+ terminal: true,
1037
+ historySize: this.opts.historySize,
1038
+ completer: this.opts.mode === "free" ? makeCompleter(this.root) : void 0
1039
+ });
1040
+ if (this.opts.banner) console.log(this.opts.banner);
1041
+ try {
1042
+ if (this.opts.mode === "free") {
1043
+ await this.freeLoop();
1044
+ } else {
1045
+ await this.drillLoop();
1046
+ }
1047
+ } finally {
1048
+ this.rl.close();
1049
+ }
1050
+ }
1051
+ // ── Drill mode ────────────────────────────────────────────────────────
1052
+ async drillLoop() {
1053
+ while (true) {
1054
+ const exited = await this.drillFrom(this.root, [this.root.name ?? "shell"]);
1055
+ if (exited) return;
1056
+ }
1057
+ }
1058
+ async drillFrom(cmd, breadcrumb) {
1059
+ while (true) {
1060
+ const token = await this.promptDrill(cmd, breadcrumb);
1061
+ if (token === null) {
1062
+ return breadcrumb.length === 1;
1063
+ }
1064
+ if (this.opts.exitCommands.includes(token)) process.exit(0);
1065
+ if (token === "..") return false;
1066
+ if (token === "help") {
1067
+ cmd.help();
1068
+ continue;
1069
+ }
1070
+ const sub = cmd.commandsArray.find((c) => c.name === token);
1071
+ if (!sub) {
1072
+ process.stderr.write(`Unknown command: ${token}
1073
+ `);
1074
+ continue;
1075
+ }
1076
+ if (sub.commandsArray.length > 0) {
1077
+ const exited = await this.drillFrom(sub, [...breadcrumb, sub.name ?? ""]);
1078
+ if (exited) return true;
1079
+ continue;
1080
+ }
1081
+ const vars = await this.gatherVariables(sub);
1082
+ const tokens = buildTokens(sub, vars);
1083
+ try {
1084
+ await sub._execute(tokens);
1085
+ } catch (err) {
1086
+ process.stderr.write(`${err instanceof Error ? err.message : err}
1087
+ `);
1088
+ }
1089
+ return false;
1090
+ }
1091
+ }
1092
+ async promptDrill(cmd, breadcrumb) {
1093
+ const subs = cmd.commandsArray.map((c) => c.name ?? "").filter(Boolean);
1094
+ const label = this.colorize(breadcrumb.join(" "));
1095
+ const choices = [...subs, "help"].join(", ");
1096
+ process.stdout.write(`
1097
+ ${label} ${choices}
1098
+ `);
1099
+ return new Promise((resolve) => {
1100
+ let resolved = false;
1101
+ const done = (val) => {
1102
+ if (!resolved) {
1103
+ resolved = true;
1104
+ resolve(val);
1105
+ }
1106
+ };
1107
+ this.rl.question("> ", (answer) => done(answer.trim() || null));
1108
+ this.rl.once("close", () => done(null));
1109
+ });
1110
+ }
1111
+ async gatherVariables(cmd) {
1112
+ const result = {};
1113
+ if (!cmd.variables) return result;
1114
+ for (const v of cmd.variables) {
1115
+ const name = v.name ?? "value";
1116
+ const hint = v.hint ? ` ${v.hint}` : "";
1117
+ while (true) {
1118
+ const answer = await new Promise((resolve) => {
1119
+ let resolved = false;
1120
+ const done = (val) => {
1121
+ if (!resolved) {
1122
+ resolved = true;
1123
+ resolve(val);
1124
+ }
1125
+ };
1126
+ this.rl.question(` ${name}${hint}: `, (ans) => done(ans.trim() || null));
1127
+ this.rl.once("close", () => done(null));
1128
+ });
1129
+ const value = answer ?? v.default ?? null;
1130
+ if (!value && v.required) {
1131
+ process.stderr.write(` ${name} is required
1132
+ `);
1133
+ continue;
1134
+ }
1135
+ if (value) {
1136
+ if (v.type === "enum" && v.enum && !v.enum.includes(value)) {
1137
+ process.stderr.write(` Must be one of: ${v.enum.join(", ")}
1138
+ `);
1139
+ continue;
1140
+ }
1141
+ result[name] = value;
1142
+ }
1143
+ break;
1144
+ }
1145
+ }
1146
+ return result;
1147
+ }
1148
+ // ── Free mode ─────────────────────────────────────────────────────────
1149
+ async freeLoop() {
1150
+ const prompt = `${this.colorize(this.opts.prompt)} > `;
1151
+ this.rl.setPrompt(prompt);
1152
+ this.rl.prompt();
1153
+ for await (const line of this.rl) {
1154
+ const trimmed = line.trim();
1155
+ if (!trimmed) {
1156
+ this.rl.prompt();
1157
+ continue;
1158
+ }
1159
+ if (this.opts.exitCommands.includes(trimmed)) break;
1160
+ const tokens = tokenize(trimmed);
1161
+ try {
1162
+ await this.root._execute(tokens);
1163
+ } catch (err) {
1164
+ process.stderr.write(`${err instanceof Error ? err.message : err}
1165
+ `);
1166
+ }
1167
+ this.rl.prompt();
1168
+ }
1169
+ }
1170
+ // ── Helpers ───────────────────────────────────────────────────────────
1171
+ colorize(text) {
1172
+ const c = this.opts.promptColor;
1173
+ if (!c || !process.stdout.isTTY) return text;
1174
+ try {
1175
+ if (c.startsWith("#")) return cosmetic2.hex(c).encoder(text);
1176
+ if (/^\d+$/.test(c)) return cosmetic2.xterm(Number(c)).encoder(text);
1177
+ const style = cosmetic2[c];
1178
+ if (style && typeof style.encoder === "function") return style.encoder(text);
1179
+ } catch {
1180
+ }
1181
+ return text;
980
1182
  }
981
1183
  };
1184
+ function tokenize(line) {
1185
+ const tokens = [];
1186
+ let current = "";
1187
+ let inQuote = null;
1188
+ for (const ch of line) {
1189
+ if (inQuote) {
1190
+ if (ch === inQuote) {
1191
+ inQuote = null;
1192
+ } else {
1193
+ current += ch;
1194
+ }
1195
+ } else if (ch === '"' || ch === "'") {
1196
+ inQuote = ch;
1197
+ } else if (ch === " " || ch === " ") {
1198
+ if (current) {
1199
+ tokens.push(current);
1200
+ current = "";
1201
+ }
1202
+ } else {
1203
+ current += ch;
1204
+ }
1205
+ }
1206
+ if (current) tokens.push(current);
1207
+ return tokens;
1208
+ }
1209
+ function buildTokens(cmd, vars) {
1210
+ if (!cmd.variables) return [];
1211
+ return cmd.variables.map((v) => vars[v.name ?? ""]).filter((v) => v !== void 0 && v !== "");
1212
+ }
1213
+ function makeCompleter(root) {
1214
+ return (line) => {
1215
+ const tokens = tokenize(line);
1216
+ let cmd = root;
1217
+ for (const token of tokens.slice(0, -1)) {
1218
+ const sub = cmd.commandsArray.find((c) => c.name === token);
1219
+ if (!sub) break;
1220
+ cmd = sub;
1221
+ }
1222
+ const partial = tokens[tokens.length - 1] ?? "";
1223
+ const names = [...cmd.commandsArray.map((c) => c.name ?? "").filter(Boolean), "help"];
1224
+ const hits = names.filter((n) => n.startsWith(partial));
1225
+ return [hits.length ? hits : names, partial];
1226
+ };
1227
+ }
982
1228
 
983
1229
  // src/models/Bar.ts
984
1230
  var _Bar = class _Bar {
@@ -2009,7 +2255,6 @@ var MultiBar = class {
2009
2255
  };
2010
2256
 
2011
2257
  // src/models/MultiSelect.ts
2012
- var CLEAR_LINE2 = "\x1B[2K";
2013
2258
  var CURSOR_UP3 = (n) => `\x1B[${n}A`;
2014
2259
  var DIM2 = "\x1B[2m";
2015
2260
  var MultiSelect = class {
@@ -2048,7 +2293,7 @@ var MultiSelect = class {
2048
2293
  const checked = /* @__PURE__ */ new Set();
2049
2294
  let error = null;
2050
2295
  let lastDrawnLines = 0;
2051
- process.stdout.write(HIDE_CURSOR);
2296
+ process.stdout.write(HIDE_CURSOR + DISABLE_WRAP);
2052
2297
  const glyph = this.promptGlyph ? `${colorText(this.promptColor, this.promptGlyph)} ` : "";
2053
2298
  const indent = " ".repeat(this.promptGlyph ? stringLength(this.promptGlyph) + 1 : 0);
2054
2299
  process.stdout.write(`${glyph}${prompt}
@@ -2058,16 +2303,26 @@ var MultiSelect = class {
2058
2303
  const q = searchQuery.toLowerCase();
2059
2304
  return items.map((item, i) => ({ item, originalIndex: i })).filter(({ item }) => item.label.toLowerCase().includes(q) || (item.description?.toLowerCase().includes(q) ?? false));
2060
2305
  };
2306
+ const computeMaxHeight = () => {
2307
+ const termRows = process.stdout.rows ?? 24;
2308
+ const reserved = 1 + (this.searchEnabled ? 1 : 0) + 1 + 1;
2309
+ const fit = Math.max(1, termRows - reserved - 1);
2310
+ return this.maxHeight ? Math.min(this.maxHeight, fit) : fit;
2311
+ };
2061
2312
  const renderList = (redraw) => {
2062
2313
  const filtered = getFiltered();
2063
2314
  if (cursor >= filtered.length) cursor = Math.max(0, filtered.length - 1);
2064
- if (this.maxHeight) {
2315
+ const maxHeight = computeMaxHeight();
2316
+ const useViewport = filtered.length > maxHeight;
2317
+ if (useViewport) {
2065
2318
  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)));
2319
+ else if (cursor >= viewportOffset + maxHeight) viewportOffset = cursor - maxHeight + 1;
2320
+ viewportOffset = Math.max(0, Math.min(viewportOffset, Math.max(0, filtered.length - maxHeight)));
2321
+ } else {
2322
+ viewportOffset = 0;
2068
2323
  }
2069
- const visibleStart = this.maxHeight ? viewportOffset : 0;
2070
- const visibleEnd = this.maxHeight ? Math.min(filtered.length, viewportOffset + this.maxHeight) : filtered.length;
2324
+ const visibleStart = useViewport ? viewportOffset : 0;
2325
+ const visibleEnd = useViewport ? Math.min(filtered.length, viewportOffset + maxHeight) : filtered.length;
2071
2326
  if (redraw) {
2072
2327
  if (lastDrawnLines > 0) process.stdout.write(CURSOR_UP3(lastDrawnLines));
2073
2328
  process.stdout.write("\r\x1B[0J");
@@ -2083,14 +2338,15 @@ var MultiSelect = class {
2083
2338
  const { item, originalIndex } = filtered[vi];
2084
2339
  const isCursor = vi === cursor;
2085
2340
  const isChecked = checked.has(originalIndex);
2341
+ const numStr = `${vi + 1}.`;
2086
2342
  const desc = item.description ? ` ${colorText(this.descriptionColor, `\u2014 ${item.description}`)}` : "";
2087
2343
  const checkMark = isChecked ? pulse ? `${pulse}${this.checkedPrefix}${RESET}` : colorText(this.promptColor, this.checkedPrefix) : this.uncheckedPrefix;
2088
2344
  const label = isCursor ? pulse ? `${pulse}${item.label}${RESET}` : colorText(this.promptColor, item.label) : item.label;
2089
- process.stdout.write(`\r${indent}${checkMark} ${label}${desc}
2345
+ process.stdout.write(`\r${indent}${numStr} ${checkMark} ${label}${desc}
2090
2346
  `);
2091
2347
  lastDrawnLines++;
2092
2348
  }
2093
- const hintContent = `\u2191\u2193 move space/tab toggle \u2190\u2192 deselect/select${this.searchEnabled ? " type to filter" : " a all"} enter confirm`;
2349
+ 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
2350
  const maxHintCols = Math.max(10, (process.stdout.columns ?? 80) - stringLength(indent) - 1);
2095
2351
  const hint = stringLength(hintContent) > maxHintCols ? hintContent.slice(0, maxHintCols) : hintContent;
2096
2352
  process.stdout.write(`\r${indent}${DIM2}${hint}${RESET}
@@ -2113,7 +2369,7 @@ var MultiSelect = class {
2113
2369
  process.stdin.setRawMode(false);
2114
2370
  process.stdin.pause();
2115
2371
  process.stdin.removeListener("data", onKey);
2116
- process.stdout.write(SHOW_CURSOR);
2372
+ process.stdout.write(ENABLE_WRAP + SHOW_CURSOR);
2117
2373
  });
2118
2374
  const cleanup = (result) => {
2119
2375
  deregisterCleanup();
@@ -2121,16 +2377,13 @@ var MultiSelect = class {
2121
2377
  clearInterval(timer);
2122
2378
  timer = null;
2123
2379
  }
2124
- if (lastDrawnLines > 0) process.stdout.write(CURSOR_UP3(lastDrawnLines));
2125
- process.stdout.write("\x1B[0J");
2126
- const bulletWidth = stringLength(this.checkedPrefix) + 1;
2127
- for (let i = 0; i < items.length; i++) {
2128
- const item = items[i];
2129
- const bullet = checked.has(i) ? `${colorText(this.promptColor, this.checkedPrefix)} ` : " ".repeat(bulletWidth);
2130
- process.stdout.write(`\r${indent}${bullet}${item.label}
2380
+ process.stdout.write(CURSOR_UP3(lastDrawnLines + 1));
2381
+ process.stdout.write("\r\x1B[0J");
2382
+ process.stdout.write(ENABLE_WRAP);
2383
+ const selectedItems = items.filter((_, i) => checked.has(i));
2384
+ const display = result !== null && selectedItems.length > 0 ? selectedItems.map((i) => i.label).join(", ") : "\u2014";
2385
+ process.stdout.write(`${glyph}${prompt}: ${display}
2131
2386
  `);
2132
- }
2133
- process.stdout.write(`\r${CLEAR_LINE2}`);
2134
2387
  process.stdin.setRawMode(false);
2135
2388
  process.stdin.pause();
2136
2389
  process.stdin.removeListener("data", onKey);
@@ -2223,7 +2476,7 @@ var MultiSelect = class {
2223
2476
  process.stdin.setRawMode(false);
2224
2477
  process.stdin.pause();
2225
2478
  process.stdin.removeListener("data", onKey);
2226
- process.stdout.write(SHOW_CURSOR);
2479
+ process.stdout.write(ENABLE_WRAP + SHOW_CURSOR);
2227
2480
  process.exit(130);
2228
2481
  } else if (this.searchEnabled) {
2229
2482
  if (str === "\x7F" || str === "\b") {
@@ -2243,7 +2496,7 @@ var MultiSelect = class {
2243
2496
  const n = parseInt(str);
2244
2497
  if (!isNaN(n) && n >= 1 && n <= Math.min(filtered.length, 9)) {
2245
2498
  error = null;
2246
- cursor = viewportOffset + n - 1;
2499
+ cursor = n - 1;
2247
2500
  renderList(true);
2248
2501
  }
2249
2502
  }
@@ -2617,7 +2870,7 @@ _Spinner.FRAMES = {
2617
2870
  var Spinner = _Spinner;
2618
2871
 
2619
2872
  // src/models/Table.ts
2620
- import cosmetic2 from "cosmetic";
2873
+ import cosmetic3 from "cosmetic";
2621
2874
 
2622
2875
  // src/utils/padSides.ts
2623
2876
  var padSides = (string, padding) => {
@@ -2695,7 +2948,7 @@ var Table = class {
2695
2948
  header += pad(column.title, column.padding + this.margin);
2696
2949
  if (i < keys.length - 1) header += this.separator;
2697
2950
  }
2698
- const styled = typeof config.color === "number" ? cosmetic2.xterm(config.color) : config.color.startsWith("#") ? cosmetic2.hex(config.color) : cosmetic2[config.color];
2951
+ const styled = typeof config.color === "number" ? cosmetic3.xterm(config.color) : config.color.startsWith("#") ? cosmetic3.hex(config.color) : cosmetic3[config.color];
2699
2952
  this.string += `${styled.underline.encoder(header)}
2700
2953
  `;
2701
2954
  for (const [ri, row] of this.rows.entries()) {
@@ -2772,7 +3025,7 @@ var commandDefaults = {};
2772
3025
  var Program = {
2773
3026
  command: (name, variables, info) => {
2774
3027
  const cmd = new Command(Object.assign({ name, variables, info }, commandDefaults));
2775
- if (!base) base = cmd;
3028
+ base = cmd;
2776
3029
  return cmd;
2777
3030
  },
2778
3031
  option: (short, long, variables, info) => new Option({ short, long, variables, info }),
@@ -2795,6 +3048,10 @@ var Program = {
2795
3048
  },
2796
3049
  setDefaults: (data) => {
2797
3050
  commandDefaults = data;
3051
+ },
3052
+ shell: async (options) => {
3053
+ if (!base) throw new Error("No command defined");
3054
+ return new Shell(base, options).run();
2798
3055
  }
2799
3056
  };
2800
3057
  export {
@@ -2811,6 +3068,7 @@ export {
2811
3068
  Program,
2812
3069
  Scrollbox,
2813
3070
  Select,
3071
+ Shell,
2814
3072
  Spinner,
2815
3073
  Table,
2816
3074
  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 +1 @@
1
- {"version":3,"file":"Command.d.ts","sourceRoot":"","sources":["../../src/models/Command.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACx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{
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,GAAG,EAAE,EAAE,KAAK,EAAE,QAAQ,GAAG,MAAM,CAGlE;AAED,wBAAgB,SAAS,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MA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