@reliverse/rempts 1.7.29 → 1.7.30

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.
Files changed (128) hide show
  1. package/README.md +92 -29
  2. package/bin/{components/animate/animate.js → libs/animate/animate-mod.js} +1 -4
  3. package/bin/{components → libs}/anykey/anykey-mod.js +2 -2
  4. package/bin/libs/confirm/confirm-alias.d.ts +1 -0
  5. package/bin/libs/confirm/confirm-alias.js +2 -0
  6. package/bin/{components/confirm/confirm-prompt.js → libs/confirm/confirm-mod.js} +1 -1
  7. package/bin/{components → libs}/editor/editor-mod.js +8 -8
  8. package/bin/{components → libs}/figures/figures-mod.d.ts +2 -3
  9. package/bin/{components → libs}/figures/figures-mod.js +1 -2
  10. package/bin/libs/input/input-alias.d.ts +4 -0
  11. package/bin/libs/input/input-alias.js +4 -0
  12. package/bin/{components/input/input-prompt.js → libs/input/input-mod.js} +2 -2
  13. package/bin/libs/intro/intro-alias.d.ts +2 -0
  14. package/bin/libs/intro/intro-alias.js +3 -0
  15. package/bin/{components/intro/intro-start.js → libs/intro/intro-mod.js} +3 -3
  16. package/bin/libs/launcher/launcher-alias.d.ts +2 -0
  17. package/bin/libs/launcher/launcher-alias.js +2 -0
  18. package/bin/{components → libs}/launcher/launcher-mod.d.ts +37 -5
  19. package/bin/{components → libs}/launcher/launcher-mod.js +326 -205
  20. package/bin/{components → libs}/launcher/launcher-types.d.ts +1 -1
  21. package/bin/libs/launcher/trpc-orpc-support/completions.d.ts +4 -0
  22. package/bin/libs/launcher/trpc-orpc-support/completions.js +45 -0
  23. package/bin/libs/launcher/trpc-orpc-support/errors.d.ts +11 -0
  24. package/bin/libs/launcher/trpc-orpc-support/errors.js +10 -0
  25. package/bin/libs/launcher/trpc-orpc-support/index.d.ts +34 -0
  26. package/bin/libs/launcher/trpc-orpc-support/index.js +641 -0
  27. package/bin/libs/launcher/trpc-orpc-support/json-schema.d.ts +17 -0
  28. package/bin/libs/launcher/trpc-orpc-support/json-schema.js +168 -0
  29. package/bin/libs/launcher/trpc-orpc-support/json.d.ts +44 -0
  30. package/bin/libs/launcher/trpc-orpc-support/json.js +41 -0
  31. package/bin/libs/launcher/trpc-orpc-support/logging.d.ts +11 -0
  32. package/bin/libs/launcher/trpc-orpc-support/logging.js +26 -0
  33. package/bin/libs/launcher/trpc-orpc-support/parse-procedure.d.ts +2 -0
  34. package/bin/libs/launcher/trpc-orpc-support/parse-procedure.js +486 -0
  35. package/bin/libs/launcher/trpc-orpc-support/prompts.d.ts +18 -0
  36. package/bin/libs/launcher/trpc-orpc-support/prompts.js +534 -0
  37. package/bin/libs/launcher/trpc-orpc-support/standard-schema/contract.d.ts +53 -0
  38. package/bin/libs/launcher/trpc-orpc-support/standard-schema/contract.js +0 -0
  39. package/bin/libs/launcher/trpc-orpc-support/standard-schema/errors.d.ts +9 -0
  40. package/bin/libs/launcher/trpc-orpc-support/standard-schema/errors.js +47 -0
  41. package/bin/libs/launcher/trpc-orpc-support/standard-schema/utils.d.ts +3 -0
  42. package/bin/libs/launcher/trpc-orpc-support/standard-schema/utils.js +6 -0
  43. package/bin/libs/launcher/trpc-orpc-support/trpc-compat.d.ts +71 -0
  44. package/bin/libs/launcher/trpc-orpc-support/trpc-compat.js +11 -0
  45. package/bin/libs/launcher/trpc-orpc-support/types.d.ts +276 -0
  46. package/bin/libs/launcher/trpc-orpc-support/types.js +0 -0
  47. package/bin/libs/launcher/trpc-orpc-support/util.d.ts +9 -0
  48. package/bin/libs/launcher/trpc-orpc-support/util.js +9 -0
  49. package/bin/{components → libs}/msg-fmt/logger.js +1 -1
  50. package/bin/libs/multiselect/multiselect-alias.d.ts +1 -0
  51. package/bin/libs/multiselect/multiselect-alias.js +2 -0
  52. package/bin/{components/select → libs/multiselect}/multiselect-prompt.js +1 -1
  53. package/bin/{components → libs}/number/number-mod.js +1 -4
  54. package/bin/libs/outro/outro-alias.d.ts +2 -0
  55. package/bin/libs/outro/outro-alias.js +3 -0
  56. package/bin/{components/outro/outro-end.js → libs/outro/outro-mod.js} +2 -2
  57. package/bin/libs/select/aliases-alias.d.ts +1 -0
  58. package/bin/libs/select/aliases-alias.js +2 -0
  59. package/bin/{components → libs}/select/select-prompt.js +2 -2
  60. package/bin/{components → libs}/select/toggle-prompt.js +1 -1
  61. package/bin/libs/spinner/spinner-alias.d.ts +1 -0
  62. package/bin/libs/spinner/spinner-alias.js +2 -0
  63. package/bin/{components → libs}/spinner/spinner-mod.js +3 -1
  64. package/bin/{components → libs}/task/task-spin.js +1 -1
  65. package/bin/{utils → libs/utils}/colorize.d.ts +1 -1
  66. package/bin/{utils → libs/utils}/prevent.d.ts +1 -1
  67. package/bin/{utils → libs/utils}/prevent.js +2 -2
  68. package/bin/{utils → libs/utils}/prompt-end.d.ts +1 -1
  69. package/bin/{utils → libs/utils}/prompt-end.js +2 -2
  70. package/bin/{utils → libs/utils}/stream-text.d.ts +1 -1
  71. package/bin/{utils → libs/utils}/stream-text.js +2 -2
  72. package/bin/mod.d.ts +66 -41
  73. package/bin/mod.js +102 -66
  74. package/package.json +16 -2
  75. package/bin/components/aliases/aliases-mod.d.ts +0 -11
  76. package/bin/components/aliases/aliases-mod.js +0 -16
  77. /package/bin/{components/animate/animate.d.ts → libs/animate/animate-mod.d.ts} +0 -0
  78. /package/bin/{components → libs}/anykey/anykey-mod.d.ts +0 -0
  79. /package/bin/{components → libs}/cancel/cancel.d.ts +0 -0
  80. /package/bin/{components → libs}/cancel/cancel.js +0 -0
  81. /package/bin/{components/confirm/confirm-prompt.d.ts → libs/confirm/confirm-mod.d.ts} +0 -0
  82. /package/bin/{components → libs}/date/date.d.ts +0 -0
  83. /package/bin/{components → libs}/date/date.js +0 -0
  84. /package/bin/{components → libs}/editor/editor-mod.d.ts +0 -0
  85. /package/bin/{components/input/input-prompt.d.ts → libs/input/input-mod.d.ts} +0 -0
  86. /package/bin/{components/intro/intro-start.d.ts → libs/intro/intro-mod.d.ts} +0 -0
  87. /package/bin/{components → libs}/launcher/launcher-types.js +0 -0
  88. /package/bin/{components → libs}/launcher/run-command.d.ts +0 -0
  89. /package/bin/{components → libs}/launcher/run-command.js +0 -0
  90. /package/bin/{components/log/log.d.ts → libs/log/log-alias.d.ts} +0 -0
  91. /package/bin/{components/log/log.js → libs/log/log-alias.js} +0 -0
  92. /package/bin/{components → libs}/msg-fmt/colors.d.ts +0 -0
  93. /package/bin/{components → libs}/msg-fmt/colors.js +0 -0
  94. /package/bin/{components → libs}/msg-fmt/logger.d.ts +0 -0
  95. /package/bin/{components → libs}/msg-fmt/mapping.d.ts +0 -0
  96. /package/bin/{components → libs}/msg-fmt/mapping.js +0 -0
  97. /package/bin/{components → libs}/msg-fmt/messages.d.ts +0 -0
  98. /package/bin/{components → libs}/msg-fmt/messages.js +0 -0
  99. /package/bin/{components → libs}/msg-fmt/terminal.d.ts +0 -0
  100. /package/bin/{components → libs}/msg-fmt/terminal.js +0 -0
  101. /package/bin/{components → libs}/msg-fmt/variants.d.ts +0 -0
  102. /package/bin/{components → libs}/msg-fmt/variants.js +0 -0
  103. /package/bin/{components/select → libs/multiselect}/multiselect-prompt.d.ts +0 -0
  104. /package/bin/{components → libs}/next-steps/next-steps.d.ts +0 -0
  105. /package/bin/{components → libs}/next-steps/next-steps.js +0 -0
  106. /package/bin/{components → libs}/number/number-mod.d.ts +0 -0
  107. /package/bin/{components/outro/outro-end.d.ts → libs/outro/outro-mod.d.ts} +0 -0
  108. /package/bin/{components → libs}/results/results.d.ts +0 -0
  109. /package/bin/{components → libs}/results/results.js +0 -0
  110. /package/bin/{components → libs}/select/nummultiselect-prompt.d.ts +0 -0
  111. /package/bin/{components → libs}/select/nummultiselect-prompt.js +0 -0
  112. /package/bin/{components → libs}/select/numselect-prompt.d.ts +0 -0
  113. /package/bin/{components → libs}/select/numselect-prompt.js +0 -0
  114. /package/bin/{components → libs}/select/select-prompt.d.ts +0 -0
  115. /package/bin/{components → libs}/select/toggle-prompt.d.ts +0 -0
  116. /package/bin/{components → libs}/spinner/spinner-mod.d.ts +0 -0
  117. /package/bin/{components → libs}/task/progress.d.ts +0 -0
  118. /package/bin/{components → libs}/task/progress.js +0 -0
  119. /package/bin/{components → libs}/task/task-spin.d.ts +0 -0
  120. /package/bin/{utils → libs/utils}/colorize.js +0 -0
  121. /package/bin/{utils → libs/utils}/errors.d.ts +0 -0
  122. /package/bin/{utils → libs/utils}/errors.js +0 -0
  123. /package/bin/{utils → libs/utils}/system.d.ts +0 -0
  124. /package/bin/{utils → libs/utils}/system.js +0 -0
  125. /package/bin/{utils → libs/utils}/validate.d.ts +0 -0
  126. /package/bin/{utils → libs/utils}/validate.js +0 -0
  127. /package/bin/{components/ascii-art/ascii-art.d.ts → libs/visual/visual-mod.d.ts} +0 -0
  128. /package/bin/{components/ascii-art/ascii-art.js → libs/visual/visual-mod.js} +0 -0
package/README.md CHANGED
@@ -59,14 +59,13 @@ All main prompts APIs are available from the package root:
59
59
  ```ts
60
60
  import {
61
61
  // ...prompts
62
- defineCommand, runMain, defineArgs,
63
62
  inputPrompt, selectPrompt, multiselectPrompt, numberPrompt,
64
63
  confirmPrompt, togglePrompt, taskSpinPrompt, taskProgressPrompt,
65
64
  startPrompt, endPrompt, resultPrompt, nextStepsPrompt,
66
65
  // ...hooks
67
66
  useSpinner,
68
67
  // ...launcher
69
- runMain, defineCommand, defineArgs,
68
+ createCli, defineCommand, defineArgs,
70
69
  // ...types
71
70
  // ...more
72
71
  } from "@reliverse/rempts";
@@ -218,6 +217,8 @@ await main();
218
217
 
219
218
  ## Launcher
220
219
 
220
+ > **Note**: `runMain` is now an alias for `createCli` and is still supported for backward compatibility. The new `createCli` API provides a more intuitive object-based configuration format.
221
+
221
222
  ### Terminology
222
223
 
223
224
  - **Launcher/Router**: The main entry point for your CLI. Visit [CLI Launcher (Router)](#cli-launcher-router) section to learn more.
@@ -228,12 +229,12 @@ await main();
228
229
 
229
230
  #### Launcher Usage Example
230
231
 
231
- **Important**: Ensure your commands don't have `await main();`, `await runMain();`, or something like that — to prevent any unexpected behavior. Only main command should have it.
232
+ **Important**: Ensure your commands don't have `await main();`, `await createCli();`, or something like that — to prevent any unexpected behavior. Only main command should have it.
232
233
 
233
234
  ```ts
234
235
  import { relinka } from "@reliverse/relinka";
235
236
 
236
- import { defineCommand, runMain } from "@reliverse/rempts";
237
+ import { defineCommand, createCli } from "@reliverse/rempts";
237
238
 
238
239
  const main = defineCommand({
239
240
  meta: {
@@ -254,12 +255,20 @@ const main = defineCommand({
254
255
  },
255
256
  });
256
257
 
257
- await runMain(main);
258
- ```
258
+ // New object format (recommended)
259
+ await createCli({
260
+ mainCommand: main,
261
+ fileBased: {
262
+ enable: true,
263
+ cmdsRootPath: "my-cmds", // default is `./app`
264
+ },
265
+ // Optionally disable auto-exit to handle errors manually:
266
+ autoExit: false,
267
+ });
259
268
 
260
- ```ts
261
- await runMain(myCommand, {
262
- fileBasedCmds: {
269
+ // Legacy format (still supported)
270
+ await createCli(main, {
271
+ fileBased: {
263
272
  enable: true,
264
273
  cmdsRootPath: "my-cmds", // default is `./app`
265
274
  },
@@ -375,9 +384,15 @@ bun dev
375
384
  **1 Create a `src/mod.ts` file:**
376
385
 
377
386
  ```ts
378
- import { runMain, defineCommand } from "@reliverse/rempts";
387
+ import { createCli, defineCommand } from "@reliverse/rempts";
388
+
389
+ // New object format (recommended)
390
+ await createCli({
391
+ mainCommand: defineCommand({}),
392
+ });
379
393
 
380
- await runMain(defineCommand({}));
394
+ // Legacy format (still supported)
395
+ await createCli(defineCommand({}));
381
396
  ```
382
397
 
383
398
  **2 Run the following:**
@@ -406,7 +421,7 @@ bun src/mod.ts
406
421
  #### Medium Usage Example
407
422
 
408
423
  ```ts
409
- import { defineCommand, runMain } from "@reliverse/rempts";
424
+ import { defineCommand, createCli } from "@reliverse/rempts";
410
425
 
411
426
  const main = defineCommand({
412
427
  meta: {
@@ -417,7 +432,13 @@ const main = defineCommand({
417
432
  },
418
433
  });
419
434
 
420
- await runMain(main);
435
+ // New object format (recommended)
436
+ await createCli({
437
+ mainCommand: main,
438
+ });
439
+
440
+ // Legacy format (still supported)
441
+ await createCli(main);
421
442
  ```
422
443
 
423
444
  #### Classic Usage Example
@@ -430,7 +451,7 @@ import {
430
451
  inputPrompt,
431
452
  selectPrompt,
432
453
  defineCommand,
433
- runMain
454
+ createCli
434
455
  } from "@reliverse/rempts";
435
456
 
436
457
  const main = defineCommand({
@@ -469,7 +490,13 @@ const main = defineCommand({
469
490
  },
470
491
  });
471
492
 
472
- await runMain(main);
493
+ // New object format (recommended)
494
+ await createCli({
495
+ mainCommand: main,
496
+ });
497
+
498
+ // Legacy format (still supported)
499
+ await createCli(main);
473
500
  ```
474
501
 
475
502
  #### Advanced Usage Example
@@ -584,7 +611,7 @@ const mainCommand = defineCommand({
584
611
  });
585
612
 
586
613
  /**
587
- * The `runMain()` function sets up the launcher with several advanced features:
614
+ * The `createCli()` function sets up the launcher with several advanced features:
588
615
  *
589
616
  * - File-Based Commands: Enables scanning for commands within the "app" directory.
590
617
  * - Alias Mapping: Shorthand flags (e.g., `-v`) are mapped to their full names (e.g., `--verbose`).
@@ -592,8 +619,28 @@ const mainCommand = defineCommand({
592
619
  * - Negated Boolean Support: Allows flags to be negated (e.g., `--no-verbose`).
593
620
  * - Custom Unknown Flag Handler: Provides custom handling for unrecognized flags.
594
621
  */
595
- await runMain(mainCommand, {
596
- fileBasedCmds: {
622
+ // New object format (recommended)
623
+ await createCli({
624
+ mainCommand: mainCommand,
625
+ fileBased: {
626
+ enable: true, // Enables file-based command detection.
627
+ cmdsRootPath: "app", // Directory to scan for commands.
628
+ },
629
+ alias: {
630
+ v: "verbose", // Maps shorthand flag -v to --verbose.
631
+ },
632
+ strict: false, // Do not throw errors for unknown flags.
633
+ warnOnUnknown: false, // Warn when encountering unknown flags.
634
+ negatedBoolean: true, // Support for negated booleans (e.g., --no-verbose).
635
+ // unknown: (flagName) => {
636
+ // relinka("warn", "Unknown flag encountered:", flagName);
637
+ // return false;
638
+ // },
639
+ });
640
+
641
+ // Legacy format (still supported)
642
+ await createCli(mainCommand, {
643
+ fileBased: {
597
644
  enable: true, // Enables file-based command detection.
598
645
  cmdsRootPath: "app", // Directory to scan for commands.
599
646
  },
@@ -634,7 +681,7 @@ Finally, a full-featured CLI launcher without the ceremony. `@reliverse/rempts`'
634
681
  Seamlessly combines positional and named arguments with zero configuration, auto-parsing booleans, strings, numbers, arrays, and even supporting negated flags like `--no-flag`.
635
682
 
636
683
  - **Customizable Behavior:**
637
- Options such as `fileBasedCmds.enable`, `cmdsRootPath`, and `autoExit` allow you to tailor the launcher's behavior. For example, you can choose whether the process should exit automatically on error or allow manual error handling.
684
+ Options such as `fileBased.enable`, `cmdsRootPath`, and `autoExit` allow you to tailor the launcher's behavior. For example, you can choose whether the process should exit automatically on error or allow manual error handling.
638
685
 
639
686
  - **Error Management & Usage Output:**
640
687
  The launcher provides clear error messages for missing required arguments, invalid types, or command import issues, and it automatically displays usage information for your CLI.
@@ -833,7 +880,7 @@ export default defineCommand({
833
880
  Below is a demonstration of how to define and use all supported argument types in rempts: positional, boolean, string, number, and array. This includes example CLI invocations and the resulting parsed output.
834
881
 
835
882
  ```ts
836
- import { defineCommand, runMain } from "@reliverse/rempts";
883
+ import { defineCommand, createCli } from "@reliverse/rempts";
837
884
 
838
885
  const main = defineCommand({
839
886
  meta: {
@@ -877,7 +924,13 @@ const main = defineCommand({
877
924
  },
878
925
  });
879
926
 
880
- await runMain(main);
927
+ // New object format (recommended)
928
+ await createCli({
929
+ mainCommand: main,
930
+ });
931
+
932
+ // Legacy format (still supported)
933
+ await createCli(main);
881
934
  ```
882
935
 
883
936
  ### Example CLI Invocations
@@ -1048,13 +1101,7 @@ The validation happens after type casting, so for example with numbers, the inpu
1048
1101
 
1049
1102
  Bug report? Prompt idea? Want to build the best DX possible?
1050
1103
 
1051
- You're in the right place:
1052
-
1053
- - ✨ [Star the repo](https://github.com/reliverse/rempts)
1054
- - 💬 [Join the Discord](https://discord.gg/3GawfWfAPe)
1055
- - ❤️ [Sponsor @blefnk](https://github.com/sponsors/blefnk)
1056
-
1057
- > *No classes. No magic. Just clean, composable tools for CLI devs.*
1104
+ You're in the right place! Please help us make the best CLI toolkit possible.
1058
1105
 
1059
1106
  ### Notices For Contributors
1060
1107
 
@@ -1078,6 +1125,10 @@ All APIs are fully typed. See [`src/types.ts`](./src/types.ts) for advanced cust
1078
1125
 
1079
1126
  - [CLI application with the Node.js Readline module](https://dev.to/camptocamp-geo/cli-application-with-the-nodejs-readline-module-48ic)
1080
1127
 
1128
+ ## TODO
1129
+
1130
+ - [ ] migrate to `dler libs` in the future (all main components will be published as separate packages; `@reliverse/rempts` will be a wrapper for all of them)
1131
+
1081
1132
  ## Related
1082
1133
 
1083
1134
  - [`@reliverse/cli`](https://npmjs.com/package/@reliverse/cli) – CLI-first toolkit for fullstack workflows
@@ -1089,6 +1140,18 @@ All APIs are fully typed. See [`src/types.ts`](./src/types.ts) for advanced cust
1089
1140
 
1090
1141
  - [citty](https://github.com/unjs/citty#readme) - launcher design inspiration
1091
1142
 
1143
+ ## Support
1144
+
1145
+ Bug report? Prompt idea? Want to build the best DX possible?
1146
+
1147
+ You're in the right place:
1148
+
1149
+ - ✨ [Star the repo](https://github.com/reliverse/rempts)
1150
+ - 💬 [Join the Discord](https://discord.gg/3GawfWfAPe)
1151
+ - ❤️ [Sponsor @blefnk](https://github.com/sponsors/blefnk)
1152
+
1153
+ > *No classes. No magic. Just clean, composable tools for CLI devs.*
1154
+
1092
1155
  ## License
1093
1156
 
1094
- 💖 MIT © [blefnk (Nazar Kornienko)](https://github.com/blefnk)
1157
+ 💖 MIT (see [LICENSE](./LICENSE) and [LICENCES](./LICENSES)) © [blefnk (Nazar Kornienko)](https://github.com/blefnk)
@@ -3,10 +3,7 @@ import {
3
3
  } from "@figliolia/chalk-animation";
4
4
  import { relinka } from "@reliverse/relinka";
5
5
  import { msg } from "../msg-fmt/messages.js";
6
- import {
7
- deleteLastLine,
8
- getTerminalWidth
9
- } from "../msg-fmt/terminal.js";
6
+ import { deleteLastLine, getTerminalWidth } from "../msg-fmt/terminal.js";
10
7
  export const animationMap = {
11
8
  rainbow: ChalkAnimation.rainbow,
12
9
  pulse: ChalkAnimation.pulse,
@@ -1,8 +1,8 @@
1
1
  import logUpdate from "log-update";
2
2
  import { cursor } from "sisteransi";
3
3
  import { fmt } from "../msg-fmt/messages.js";
4
- import { outroPrompt } from "../outro/outro-end.js";
5
- import { streamText } from "../../utils/stream-text.js";
4
+ import { outroPrompt } from "../outro/outro-mod.js";
5
+ import { streamText } from "../utils/stream-text.js";
6
6
  const DEFAULT_MESSAGE = "Press any key to continue...";
7
7
  const CTRL_C_CODE = 3;
8
8
  const terminal = {
@@ -0,0 +1 @@
1
+ export declare const confirm: any;
@@ -0,0 +1,2 @@
1
+ import { confirmPrompt } from "./confirm-mod.js";
2
+ export const confirm = confirmPrompt;
@@ -3,7 +3,7 @@ import { stdin as input, stdout as output } from "node:process";
3
3
  import readline from "node:readline/promises";
4
4
  import { bar, msg } from "../msg-fmt/messages.js";
5
5
  import { deleteLastLine } from "../msg-fmt/terminal.js";
6
- import { completePrompt } from "../../utils/prompt-end.js";
6
+ import { completePrompt } from "../utils/prompt-end.js";
7
7
  function renderPrompt(params) {
8
8
  const {
9
9
  title,
@@ -192,11 +192,11 @@ function renderEditor() {
192
192
  const lineNum = String(fileLineIndex + 1).padStart(3);
193
193
  term(state.theme.lineNumber(`${lineNum} `));
194
194
  const line = state.lines[fileLineIndex];
195
- const displayLine = line.substring(
195
+ const displayLine = line?.substring(
196
196
  state.leftCol,
197
197
  state.leftCol + displayWidth
198
198
  );
199
- const highlightedDisplayLine = applySyntaxHighlighting(displayLine);
199
+ const highlightedDisplayLine = applySyntaxHighlighting(displayLine ?? "");
200
200
  term(highlightedDisplayLine);
201
201
  term.eraseLineAfter();
202
202
  } else {
@@ -237,8 +237,8 @@ function deleteCharBackward() {
237
237
  const currentLine = state.lines.splice(state.cursorY, 1)[0];
238
238
  state.cursorY--;
239
239
  const prevLine = state.lines[state.cursorY];
240
- state.cursorX = prevLine.length;
241
- state.lines[state.cursorY] = prevLine + currentLine;
240
+ state.cursorX = prevLine?.length ?? 0;
241
+ state.lines[state.cursorY] = prevLine + (currentLine ?? "");
242
242
  updateModifiedStatus();
243
243
  }
244
244
  }
@@ -368,7 +368,7 @@ async function confirmAction(promptMessage = "Are you sure? (y/N)") {
368
368
  no: ["n", "N", "ENTER"]
369
369
  }).promise;
370
370
  term.moveTo(1, term.height).eraseLine();
371
- return confirm;
371
+ return confirm ?? false;
372
372
  } catch (_error) {
373
373
  term.moveTo(1, term.height).eraseLine();
374
374
  state.statusMessage = "Cancelled";
@@ -537,7 +537,7 @@ async function findText() {
537
537
  for (let y = state.cursorY; y < state.lines.length; y++) {
538
538
  const line = state.lines[y];
539
539
  const startIdx = y === state.cursorY ? state.cursorX + 1 : 0;
540
- const matchIndex = line.indexOf(termToUse, startIdx);
540
+ const matchIndex = line?.indexOf(termToUse, startIdx) ?? -1;
541
541
  if (matchIndex !== -1) {
542
542
  state.cursorY = y;
543
543
  state.cursorX = matchIndex;
@@ -549,8 +549,8 @@ async function findText() {
549
549
  state.statusMessage = `Search wrapped: ${termToUse}`;
550
550
  for (let y = 0; y <= state.cursorY; y++) {
551
551
  const line = state.lines[y];
552
- const endIdx = y === state.cursorY ? state.cursorX + 1 : line.length;
553
- const matchIndex = line.substring(0, endIdx).indexOf(termToUse);
552
+ const endIdx = y === state.cursorY ? state.cursorX + 1 : line?.length ?? 0;
553
+ const matchIndex = line?.substring(0, endIdx).indexOf(termToUse) ?? -1;
554
554
  if (matchIndex !== -1) {
555
555
  state.cursorY = y;
556
556
  state.cursorX = matchIndex;
@@ -229,7 +229,7 @@ export declare const mainSymbols: {
229
229
  lineSlash: string;
230
230
  };
231
231
  export declare const fallbackSymbols: Record<string, string>;
232
- declare const figures: {
232
+ export declare const figures: Record<string, string> | {
233
233
  tick: string;
234
234
  info: string;
235
235
  warning: string;
@@ -458,5 +458,4 @@ declare const figures: {
458
458
  lineCross: string;
459
459
  lineBackslash: string;
460
460
  lineSlash: string;
461
- } | Record<string, string>;
462
- export default figures;
461
+ };
@@ -282,5 +282,4 @@ export const fallbackSymbols = {
282
282
  ...specialFallbackSymbols
283
283
  };
284
284
  const shouldUseMain = isUnicodeSupported();
285
- const figures = shouldUseMain ? mainSymbols : fallbackSymbols;
286
- export default figures;
285
+ export const figures = shouldUseMain ? mainSymbols : fallbackSymbols;
@@ -0,0 +1,4 @@
1
+ import type { InputPromptOptions } from "../../types.js";
2
+ export declare const input: any;
3
+ export declare const text: any;
4
+ export declare const password: (options: Omit<InputPromptOptions, "mode">) => any;
@@ -0,0 +1,4 @@
1
+ import { inputPrompt } from "./input-mod.js";
2
+ export const input = inputPrompt;
3
+ export const text = inputPrompt;
4
+ export const password = (options) => inputPrompt({ ...options, mode: "password" });
@@ -3,8 +3,8 @@ import { isUnicodeSupported } from "@reliverse/runtime";
3
3
  import readline from "node:readline/promises";
4
4
  import { bar, msg, msgUndoAll } from "../msg-fmt/messages.js";
5
5
  import { deleteLastLine } from "../msg-fmt/terminal.js";
6
- import { completePrompt } from "../../utils/prompt-end.js";
7
- import { streamText } from "../../utils/stream-text.js";
6
+ import { completePrompt } from "../utils/prompt-end.js";
7
+ import { streamText } from "../utils/stream-text.js";
8
8
  const unicode = isUnicodeSupported();
9
9
  const S_MASK = unicode ? "\u258B" : "*";
10
10
  function getMaskChar(customMask) {
@@ -0,0 +1,2 @@
1
+ export declare const startPrompt: any;
2
+ export declare const intro: any;
@@ -0,0 +1,3 @@
1
+ import { introPrompt } from "./intro-mod.js";
2
+ export const startPrompt = introPrompt;
3
+ export const intro = introPrompt;
@@ -1,6 +1,5 @@
1
1
  import { relinka } from "@reliverse/relinka";
2
2
  import { getCurrentTerminalName } from "@reliverse/runtime";
3
- import { createAsciiArt } from "../ascii-art/ascii-art.js";
4
3
  import { msg } from "../msg-fmt/messages.js";
5
4
  import {
6
5
  getExactTerminalWidth,
@@ -11,8 +10,9 @@ import {
11
10
  preventWrongTerminalSize,
12
11
  preventWindowsHomeDirRoot,
13
12
  preventUnsupportedTTY
14
- } from "../../utils/prevent.js";
15
- import { pm, reliversePrompts } from "../../utils/system.js";
13
+ } from "../utils/prevent.js";
14
+ import { pm, reliversePrompts } from "../utils/system.js";
15
+ import { createAsciiArt } from "../visual/visual-mod.js";
16
16
  export async function introPrompt(optionsOrTitle) {
17
17
  const options = typeof optionsOrTitle === "string" ? { title: optionsOrTitle } : optionsOrTitle;
18
18
  const {
@@ -0,0 +1,2 @@
1
+ import { createCli } from "./launcher-mod";
2
+ export declare const runMain: typeof createCli;
@@ -0,0 +1,2 @@
1
+ import { createCli } from "./launcher-mod.js";
2
+ export const runMain = createCli;
@@ -1,5 +1,5 @@
1
1
  import type { ReliArgParserOptions } from "@reliverse/reliarg";
2
- import type { ArgDefinitions, Command, DefineCommandOptions, EmptyArgs, FileBasedCmdsOptions } from "./launcher-types.js";
2
+ import type { ArgDefinitions, Command, DefineCommandOptions, EmptyArgs, FileBasedOptions } from "./launcher-types.js";
3
3
  /**
4
4
  * Defines a command with metadata, argument definitions,
5
5
  * an execution function, and (optional) subCommands.
@@ -9,7 +9,7 @@ export declare function defineCommand<A extends ArgDefinitions = EmptyArgs>(opti
9
9
  * Show usage for a given command.
10
10
  */
11
11
  export declare function showUsage<A extends ArgDefinitions>(command: Command<A>, parserOptions?: ReliArgParserOptions & {
12
- fileBasedCmds?: FileBasedCmdsOptions;
12
+ fileBased?: FileBasedOptions;
13
13
  autoExit?: boolean;
14
14
  metaSettings?: {
15
15
  showDescriptionOnMain?: boolean;
@@ -17,6 +17,10 @@ export declare function showUsage<A extends ArgDefinitions>(command: Command<A>,
17
17
  _fileBasedCurrentDir?: string;
18
18
  _fileBasedPathSegments?: string[];
19
19
  _isSubcommand?: boolean;
20
+ }, globalCliMeta?: {
21
+ name?: string;
22
+ version?: string;
23
+ description?: string;
20
24
  }): Promise<void>;
21
25
  /**
22
26
  * Primary entry point to run a command. This function supports:
@@ -28,13 +32,41 @@ export declare function showUsage<A extends ArgDefinitions>(command: Command<A>,
28
32
  * This function passes along remaining arguments to command runners to ensure
29
33
  * consistent parsing.
30
34
  */
31
- export declare function runMain<A extends ArgDefinitions = EmptyArgs>(command: Command<A>, parserOptions?: ReliArgParserOptions & {
32
- fileBasedCmds?: FileBasedCmdsOptions;
35
+ export declare function createCli<A extends ArgDefinitions = EmptyArgs>(options: Command<A> | {
36
+ name?: string;
37
+ version?: string;
38
+ description?: string;
39
+ mainCommand?: Command<A>;
40
+ fileBased?: FileBasedOptions;
33
41
  autoExit?: boolean;
34
42
  metaSettings?: {
35
43
  showDescriptionOnMain?: boolean;
36
44
  };
37
- }): Promise<void>;
45
+ meta?: Command<A>["meta"];
46
+ args?: Command<A>["args"];
47
+ run?: Command<A>["run"];
48
+ commands?: Command<A>["commands"];
49
+ onCmdInit?: Command<A>["onCmdInit"];
50
+ onCmdExit?: Command<A>["onCmdExit"];
51
+ onLauncherInit?: Command<A>["onLauncherInit"];
52
+ onLauncherExit?: Command<A>["onLauncherExit"];
53
+ }, legacyParserOptions?: ReliArgParserOptions & {
54
+ fileBased?: FileBasedOptions;
55
+ autoExit?: boolean;
56
+ metaSettings?: {
57
+ showDescriptionOnMain?: boolean;
58
+ };
59
+ }): {
60
+ /**
61
+ * @deprecated Use createCli() directly instead. This method will be removed in a future version.
62
+ * @example
63
+ * // Instead of:
64
+ * createCli({...}).run()
65
+ * // Use:
66
+ * await createCli({...})
67
+ */
68
+ run(_ctx?: any): Promise<void>;
69
+ };
38
70
  /**
39
71
  * Helper to define argument definitions with improved type inference
40
72
  * for IntelliSense and validation for array defaults against options.