@reliverse/rempts 1.6.1 → 1.7.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.
Files changed (89) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +120 -27
  3. package/bin/{core-impl → components}/anykey/anykey-mod.d.ts +1 -1
  4. package/bin/{core-impl → components}/anykey/anykey-mod.js +1 -1
  5. package/bin/{core-impl → components}/date/date.d.ts +1 -1
  6. package/bin/{core-impl → components}/editor/editor-mod.d.ts +1 -1
  7. package/bin/{core-impl → components}/editor/editor-mod.js +7 -7
  8. package/bin/{core-impl → components}/input/confirm-prompt.d.ts +1 -1
  9. package/bin/{core-impl → components}/input/confirm-prompt.js +1 -1
  10. package/bin/{core-impl → components}/input/input-prompt.d.ts +1 -1
  11. package/bin/{core-impl → components}/input/input-prompt.js +3 -7
  12. package/bin/{core-impl → components}/launcher/deprecated/_parser.ts.txt +1 -1
  13. package/bin/{core-impl → components}/launcher/deprecated/_utils.ts.txt +1 -1
  14. package/bin/{core-impl → components}/launcher/deprecated/args.ts.txt +1 -1
  15. package/bin/{core-impl → components}/launcher/deprecated/command.ts.txt +1 -1
  16. package/bin/{core-impl → components}/launcher/deprecated/launcher-mod.ts.txt +1 -1
  17. package/bin/{core-impl → components}/launcher/deprecated/usage.ts.txt +1 -1
  18. package/bin/components/launcher/launcher-mod.d.ts +133 -0
  19. package/bin/components/launcher/launcher-mod.js +610 -0
  20. package/bin/{core-impl → components}/msg-fmt/colors.d.ts +1 -1
  21. package/bin/{core-impl → components}/msg-fmt/logger.d.ts +1 -1
  22. package/bin/{core-impl → components}/msg-fmt/logger.js +1 -4
  23. package/bin/{core-impl → components}/msg-fmt/mapping.d.ts +1 -1
  24. package/bin/{core-impl → components}/msg-fmt/messages.d.ts +1 -1
  25. package/bin/{core-impl → components}/msg-fmt/variants.d.ts +1 -1
  26. package/bin/{core-impl → components}/next-steps/next-steps.d.ts +2 -2
  27. package/bin/{core-impl → components}/number/number-mod.d.ts +1 -1
  28. package/bin/{core-impl → components}/select/multiselect-prompt.d.ts +1 -1
  29. package/bin/{core-impl → components}/select/multiselect-prompt.js +1 -1
  30. package/bin/{core-impl → components}/select/nummultiselect-prompt.d.ts +1 -1
  31. package/bin/{core-impl → components}/select/numselect-prompt.d.ts +1 -1
  32. package/bin/{core-impl → components}/select/numselect-prompt.js +1 -1
  33. package/bin/{core-impl → components}/select/select-prompt.d.ts +1 -1
  34. package/bin/{core-impl → components}/select/select-prompt.js +2 -2
  35. package/bin/{core-impl → components}/select/toggle-prompt.d.ts +1 -1
  36. package/bin/{core-impl → components}/select/toggle-prompt.js +1 -1
  37. package/bin/{core-impl → components}/st-end/end.d.ts +1 -1
  38. package/bin/{core-impl → components}/st-end/start.d.ts +1 -1
  39. package/bin/{core-impl → components}/st-end/start.js +2 -2
  40. package/bin/{core-impl → components}/task/progress.d.ts +1 -1
  41. package/bin/{core-impl → components}/visual/animate/animate.d.ts +1 -1
  42. package/bin/hooks/spinner/spinner-mod.d.ts +20 -0
  43. package/bin/hooks/spinner/spinner-mod.js +26 -0
  44. package/bin/mod.d.ts +37 -0
  45. package/bin/mod.js +88 -0
  46. package/bin/{core-types.d.ts → types.d.ts} +1 -1
  47. package/bin/{core-impl/utils → utils}/colorize.d.ts +1 -1
  48. package/bin/{core-impl/utils → utils}/prevent.d.ts +1 -1
  49. package/bin/{core-impl/utils → utils}/prevent.js +2 -2
  50. package/bin/{core-impl/utils → utils}/prompt-end.d.ts +1 -1
  51. package/bin/{core-impl/utils → utils}/prompt-end.js +2 -2
  52. package/bin/{core-impl/utils → utils}/stream-text.d.ts +1 -1
  53. package/bin/{core-impl/utils → utils}/stream-text.js +2 -2
  54. package/package.json +47 -25
  55. package/bin/core-impl/figures/figures.test.d.ts +0 -1
  56. package/bin/core-impl/figures/figures.test.js +0 -474
  57. package/bin/core-impl/launcher/launcher-mod.d.ts +0 -87
  58. package/bin/core-impl/launcher/launcher-mod.js +0 -364
  59. package/bin/main.d.ts +0 -36
  60. package/bin/main.js +0 -86
  61. /package/bin/{core-impl → components}/date/date.js +0 -0
  62. /package/bin/{core-impl → components}/figures/figures-mod.d.ts +0 -0
  63. /package/bin/{core-impl → components}/figures/figures-mod.js +0 -0
  64. /package/bin/{core-impl → components}/msg-fmt/colors.js +0 -0
  65. /package/bin/{core-impl → components}/msg-fmt/mapping.js +0 -0
  66. /package/bin/{core-impl → components}/msg-fmt/messages.js +0 -0
  67. /package/bin/{core-impl → components}/msg-fmt/terminal.d.ts +0 -0
  68. /package/bin/{core-impl → components}/msg-fmt/terminal.js +0 -0
  69. /package/bin/{core-impl → components}/msg-fmt/variants.js +0 -0
  70. /package/bin/{core-impl → components}/next-steps/next-steps.js +0 -0
  71. /package/bin/{core-impl → components}/number/number-mod.js +0 -0
  72. /package/bin/{core-impl → components}/results/results.d.ts +0 -0
  73. /package/bin/{core-impl → components}/results/results.js +0 -0
  74. /package/bin/{core-impl → components}/select/nummultiselect-prompt.js +0 -0
  75. /package/bin/{core-impl → components}/st-end/end.js +0 -0
  76. /package/bin/{core-impl → components}/task/progress.js +0 -0
  77. /package/bin/{core-impl → components}/task/spinner.d.ts +0 -0
  78. /package/bin/{core-impl → components}/task/spinner.js +0 -0
  79. /package/bin/{core-impl → components}/visual/animate/animate.js +0 -0
  80. /package/bin/{core-impl → components}/visual/ascii-art/ascii-art.d.ts +0 -0
  81. /package/bin/{core-impl → components}/visual/ascii-art/ascii-art.js +0 -0
  82. /package/bin/{core-types.js → types.js} +0 -0
  83. /package/bin/{core-impl/utils → utils}/colorize.js +0 -0
  84. /package/bin/{core-impl/utils → utils}/errors.d.ts +0 -0
  85. /package/bin/{core-impl/utils → utils}/errors.js +0 -0
  86. /package/bin/{core-impl/utils → utils}/system.d.ts +0 -0
  87. /package/bin/{core-impl/utils → utils}/system.js +0 -0
  88. /package/bin/{core-impl/utils → utils}/validate.d.ts +0 -0
  89. /package/bin/{core-impl/utils → utils}/validate.js +0 -0
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  # MIT License
2
2
 
3
- Copyright (c) 2025 blefnk Nazar Kornienko
3
+ Copyright (c) Nazar Kornienko (blefnk), Reliverse
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
- # @reliverse/rempts
1
+ # rempts • powerful js/ts cli builder
2
2
 
3
- [💬 Discord](https://discord.gg/3GawfWfAPe) [📦 NPM](https://npmjs.com/package/@reliverse/rempts) [🧠 Docs](https://docs.reliverse.org/reliverse/rempts) [🌐 JSR](https://jsr.io/@reliverse/rempts) [✨ GitHub](https://github.com/reliverse/rempts)
3
+ > @reliverse/rempts is a modern, type-safe toolkit for building delightful cli experiences. it's fast, flexible, and made for developer happiness. file-based commands keep things simple—no clutter, just clean and easy workflows. this is how cli should feel.
4
4
 
5
- > @reliverse/rempts is a prompt library built for modern CLI devs. Fast. Type-safe. Unreasonably delightful.
5
+ [💬 Discord](https://discord.gg/3GawfWfAPe) [📦 NPM](https://npmjs.com/package/@reliverse/rempts) [🧠 Docs](https://docs.reliverse.org/reliverse/rempts) [🌐 JSR](https://jsr.io/@reliverse/rempts) [✨ GitHub](https://github.com/reliverse/rempts)
6
6
 
7
7
  ## Stop Fighting Your CLI
8
8
 
@@ -12,6 +12,7 @@
12
12
 
13
13
  ## What Makes It Different?
14
14
 
15
+ - 📂 File-based commands (optional)
15
16
  - 🧠 Type-safe from args to prompts
16
17
  - 🎨 Customizable themes, styled output
17
18
  - 🧩 Router + argument parser built-in
@@ -20,16 +21,22 @@
20
21
  - 🏎️ Prompt engine that *feels* modern, actually is
21
22
  - 🧪 Scriptable for testing, stable for production
22
23
  - 🚨 Crash-safe (Ctrl+C, SIGINT, errors)
24
+ - 🆕 Automatic commands creation via `rempts init --cmd my-cool-cmd`
23
25
 
24
26
  ## Screenshot
25
27
 
26
28
  ![Rempts Example CLI Screenshot](./example.png)
27
29
 
28
- ## CLI Launcher (Router)
30
+ ## Terminology
31
+
32
+ - **Command/Subcommand**: A command is a function that defines the behavior of a CLI.
33
+ - **Argument**: An argument is a value that is passed to a command.
34
+ - **Flag**: A flag is a boolean argument that is used to enable or disable a feature.
35
+ - **Option**: An option is a named argument that is used to configure a command.
29
36
 
30
- Finally, a full-featured CLI launcher without the ceremony. The launcher supports both programmatically defined subcommands and file-based routing, so you can structure your CLI however you like. It automatically detects and loads subcommands from your filesystem and provides robust usage and error handling out-of-the-box.
37
+ ## CLI Launcher (Router)
31
38
 
32
- **Key Features:**
39
+ Finally, a full-featured CLI launcher without the ceremony. `@reliverse/rempts`'s so called "launcher" is a uniquely powerful and ergonomic CLI toolkit—one that helps you build delightful developer experiences with less code and more confidence. The launcher supports both programmatically defined subcommands and file-based routing, so you can structure your CLI however you like. It automatically detects and loads subcommands from your filesystem and provides robust usage and error handling out-of-the-box. The launcher is more than just a command runner—it's a robust, developer-friendly engine with several advanced features and thoughtful design choices:
33
40
 
34
41
  - **File-Based & Defined Subcommands:**
35
42
  Use `subCommands` in your command definition or let the launcher automatically load commands from a specified directory.
@@ -56,13 +63,70 @@ Finally, a full-featured CLI launcher without the ceremony. The launcher support
56
63
  - **Error Management & Usage Output:**
57
64
  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.
58
65
 
59
- **Usage Example:**
66
+ - **Lifecycle Hooks:**
67
+ - You can define optional `setup` and `cleanup` functions in your main command. These hooks are called automatically before and after any command or subcommand runs (including file-based and programmatic subcommands). This is perfect for initializing resources or cleaning up after execution.
68
+
69
+ - **Dynamic Usage Examples:**
70
+ - The launcher inspects your available subcommands and their argument definitions, then prints a plausible example CLI invocation for a random subcommand directly in the help output. This helps users understand real-world usage at a glance.
71
+
72
+ - **File-Based & Programmatic Subcommands:**
73
+ - Both file-based and object subcommands are fully supported. The launcher can introspect their argument definitions and metadata for help, usage, and validation.
74
+ - File-based subcommands are auto-discovered from your filesystem, while programmatic subcommands can be defined inline in your main command.
75
+
76
+ - **Context-Aware Help Output:**
77
+ - The help/usage output adapts to your CLI's structure, showing available subcommands, their aliases, argument details, and even dynamic usage examples. It also displays global options and context-specific error messages.
78
+
79
+ - **Error Handling:**
80
+ - The launcher provides clear, actionable error messages for missing required arguments, invalid types, unknown commands, and import errors. It always shows relevant usage information to help users recover quickly.
81
+
82
+ - **Unified Argument Parsing:**
83
+ - All arguments (positional, named, boolean, string, number, array) are parsed and validated automatically. Negated flags (like `--no-flag`) are supported out of the box.
84
+
85
+ - **Extensible & Flexible:**
86
+ - The launcher is highly extensible. You can use it with both Bun and Node.js, and it works seamlessly with both file-based and programmatic command definitions. You can also customize its behavior with options like `autoExit`, `cmdsRootPath`, and more.
87
+
88
+ - **Bun & Node.js Support:**
89
+ - The launcher is designed to work in both Bun and Node.js environments, so you can use it in any modern JavaScript/TypeScript project.
90
+
91
+ - **Prompt-First, Modern UX:**
92
+ - The launcher integrates tightly with the prompt engine, so you can build interactive, delightful CLIs with minimal effort.
93
+
94
+ ### Launcher Usage Example
95
+
96
+ ‼️ Go to [Usage Examples](#usage-examples) section for a more detailed example.
97
+
98
+ ```ts
99
+ import { relinka } from "@reliverse/relinka";
100
+
101
+ import { defineCommand, runMain } from "~/mod.js";
102
+
103
+ const main = defineCommand({
104
+ meta: {
105
+ name: "rempts",
106
+ version: "1.0.0",
107
+ description: "Rempts Launcher Playground CLI",
108
+ },
109
+ setup() {
110
+ relinka("success", "Setup");
111
+ },
112
+ cleanup() {
113
+ relinka("success", "Cleanup");
114
+ },
115
+ subCommands: {
116
+ build: () => import("./app/build/cmd.js").then((r) => r.default),
117
+ deploy: () => import("./app/deploy/cmd.js").then((r) => r.default),
118
+ debug: () => import("./app/debug/cmd.js").then((r) => r.default),
119
+ },
120
+ });
121
+
122
+ await runMain(main);
123
+ ```
60
124
 
61
125
  ```ts
62
126
  await runMain(myCommand, {
63
127
  fileBasedCmds: {
64
128
  enable: true,
65
- cmdsRootPath: "./cli/args",
129
+ cmdsRootPath: "./cli/args", // default is `./app`
66
130
  },
67
131
  // Optionally disable auto-exit to handle errors manually:
68
132
  autoExit: false,
@@ -73,9 +137,10 @@ This flexibility allows you to easily build a rich, multi-command CLI with minim
73
137
 
74
138
  ### File-Based Subcommands
75
139
 
76
- Drop a `./src/cli/args/add/index.ts` and it's live.
140
+ Drop a `./src/cli/app/add/index.ts` and it's live.
77
141
 
78
142
  ```ts
143
+ import { defineArgs, defineCommand } from "@reliverse/rempts";
79
144
  export default defineCommand({
80
145
  meta: {
81
146
  name: "add",
@@ -83,11 +148,11 @@ export default defineCommand({
83
148
  description: "Add stuff to your project",
84
149
  },
85
150
  args: {
86
- name: {
151
+ name: defineArgs({ // 💡 PRO TIP: use defineArgs() to get fully correct intellisense
87
152
  type: "string",
88
153
  required: true,
89
154
  description: "Name of what to add",
90
- },
155
+ }),
91
156
  },
92
157
  async run({ args }) {
93
158
  relinka("info", "Adding:", args.name);
@@ -168,8 +233,37 @@ bun dev # supported options: name
168
233
  - Both `rempts examples` from @reliverse/rempts and `bun dev` (which is the same thing) are themselves examples of `launcher` functionality.
169
234
  - This launcher will show you a `multiselectPrompt()` where you can choose which CLI prompts you want to play with.
170
235
 
236
+ ## Usage Examples
237
+
171
238
  ### Minimal Usage Example
172
239
 
240
+ **1 Create a `src/mod.ts` file:**
241
+
242
+ ```ts
243
+ import { runMain, defineCommand } from "@reliverse/rempts";
244
+
245
+ await runMain(defineCommand({}));
246
+ ```
247
+
248
+ **2 Run the following:**
249
+
250
+ ```bash
251
+ bun add -D @reliverse/dler # or: bun i -g @reliverse/dler
252
+ bun dler init --cmd my-cmd-1 # or: dler init my-cmd-1 my-cmd-2 --main src/mod.ts
253
+ # * `--main` is optional, default is `./src/mod.ts`
254
+ # * you can specify multiple commands at once
255
+ ```
256
+
257
+ **3 Visit `src/app/my-cmd-1/mod.ts` and edit it:**
258
+
259
+ ```ts
260
+ export default defineCommand({
261
+ run() { console.log("Hello, world!"); },
262
+ });
263
+ ```
264
+
265
+ ### Medium Usage Example
266
+
173
267
  ```ts
174
268
  import { defineCommand, runMain } from "@reliverse/rempts";
175
269
 
@@ -185,7 +279,7 @@ const main = defineCommand({
185
279
  await runMain(main);
186
280
  ```
187
281
 
188
- ### Medium Usage Example
282
+ ### Classic Usage Example
189
283
 
190
284
  ```ts
191
285
  import { relinka } from "@reliverse/relinka";
@@ -207,7 +301,7 @@ const main = defineCommand({
207
301
  args: {
208
302
  name: {
209
303
  type: "string",
210
- required: false,
304
+ required: true,
211
305
  description: "The name of the project",
212
306
  },
213
307
  },
@@ -218,7 +312,7 @@ const main = defineCommand({
218
312
 
219
313
  const name = await inputPrompt({
220
314
  title: "What's your project name?",
221
- placeholder: args.name ?? "my-cool-cli",
315
+ placeholder: args.name,
222
316
  });
223
317
 
224
318
  const framework = await selectPrompt({
@@ -256,7 +350,7 @@ import {
256
350
  * This command demonstrates the full range of launcher features along with all supported argument types:
257
351
  *
258
352
  * - Global Usage Handling: Automatically processes `--help` and `--version`.
259
- * - File-Based Subcommands: Scans "src/cli/args" for subcommands (e.g., `init`).
353
+ * - File-Based Subcommands: Scans "app" for subcommands (e.g., `init`).
260
354
  * - Comprehensive Argument Parsing: Supports positional, boolean, string, number, and array arguments.
261
355
  * - Interactive Prompts: Uses built-in prompt functions for an engaging CLI experience.
262
356
  */
@@ -271,12 +365,10 @@ const mainCommand = defineCommand({
271
365
  // Positional arguments
272
366
  inputFile: {
273
367
  type: "positional",
274
- required: false,
275
368
  description: "Path to the input file (only for the main command).",
276
369
  },
277
370
  config: {
278
371
  type: "positional",
279
- required: false,
280
372
  description: "Path to the configuration file.",
281
373
  },
282
374
  // Boolean arguments
@@ -293,20 +385,17 @@ const mainCommand = defineCommand({
293
385
  // String argument
294
386
  name: {
295
387
  type: "string",
296
- required: false,
297
388
  description: "The name of the project.",
298
389
  },
299
390
  // Number argument
300
391
  timeout: {
301
392
  type: "number",
302
- required: false,
303
393
  default: 30,
304
394
  description: "Timeout in seconds for the CLI operation.",
305
395
  },
306
396
  // Array argument
307
397
  tags: {
308
398
  type: "array",
309
- required: false,
310
399
  default: ["cli", "rempts"],
311
400
  description: "List of tags associated with the project.",
312
401
  },
@@ -356,7 +445,7 @@ const mainCommand = defineCommand({
356
445
  /**
357
446
  * The `runMain()` function sets up the launcher with several advanced features:
358
447
  *
359
- * - File-Based Subcommands: Enables scanning for subcommands within the "src/cli/args" directory.
448
+ * - File-Based Subcommands: Enables scanning for subcommands within the "app" directory.
360
449
  * - Alias Mapping: Shorthand flags (e.g., `-v`) are mapped to their full names (e.g., `--verbose`).
361
450
  * - Strict Mode & Unknown Flag Warnings: Unknown flags are either warned about or handled via a callback.
362
451
  * - Negated Boolean Support: Allows flags to be negated (e.g., `--no-verbose`).
@@ -365,18 +454,18 @@ const mainCommand = defineCommand({
365
454
  await runMain(mainCommand, {
366
455
  fileBasedCmds: {
367
456
  enable: true, // Enables file-based subcommand detection.
368
- cmdsRootPath: "src/cli/args", // Directory to scan for subcommands.
457
+ cmdsRootPath: "app", // Directory to scan for subcommands.
369
458
  },
370
459
  alias: {
371
460
  v: "verbose", // Maps shorthand flag -v to --verbose.
372
461
  },
373
462
  strict: false, // Do not throw errors for unknown flags.
374
- warnOnUnknown: true, // Warn when encountering unknown flags.
463
+ warnOnUnknown: false, // Warn when encountering unknown flags.
375
464
  negatedBoolean: true, // Support for negated booleans (e.g., --no-verbose).
376
- unknown: (flagName) => {
377
- relinka("warn", "Unknown flag encountered:", flagName);
378
- return false;
379
- },
465
+ // unknown: (flagName) => {
466
+ // relinka("warn", "Unknown flag encountered:", flagName);
467
+ // return false;
468
+ // },
380
469
  });
381
470
  ```
382
471
 
@@ -392,6 +481,10 @@ You're in the right place:
392
481
 
393
482
  > *No classes. No magic. Just clean, composable tools for CLI devs.*
394
483
 
484
+ ### Helpful Links
485
+
486
+ - [CLI application with the Node.js Readline module](https://dev.to/camptocamp-geo/cli-application-with-the-nodejs-readline-module-48ic)
487
+
395
488
  ## Related
396
489
 
397
490
  - [`@reliverse/cli`](https://npmjs.com/package/@reliverse/cli) – CLI-first toolkit for fullstack workflows
@@ -1,4 +1,4 @@
1
- import type { ColorName } from "../../core-types.js";
1
+ import type { ColorName } from "../../types.js";
2
2
  type Options = {
3
3
  ctrlC?: number | false | "reject";
4
4
  preserveLog?: boolean;
@@ -2,7 +2,7 @@ import logUpdate from "log-update";
2
2
  import { cursor } from "sisteransi";
3
3
  import { fmt } from "../msg-fmt/messages.js";
4
4
  import { endPrompt } from "../st-end/end.js";
5
- import { streamText } from "../utils/stream-text.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 = {
@@ -1,2 +1,2 @@
1
- import type { DatePromptOptions } from "../../core-types.js";
1
+ import type { DatePromptOptions } from "../../types.js";
2
2
  export declare function datePrompt(opts: DatePromptOptions): Promise<string>;
@@ -1,4 +1,4 @@
1
- import type { EditorExitResult } from "../../core-types.js";
1
+ import type { EditorExitResult } from "../../types.js";
2
2
  type EditorConfig = {
3
3
  syntaxHighlighting?: boolean;
4
4
  theme?: "auto" | "light" | "dark";
@@ -43,11 +43,11 @@ let state = {
43
43
  theme: {
44
44
  // Default Light Theme
45
45
  text: (str) => str,
46
- statusBarBg: (str) => re.bgGray(str),
46
+ statusBarBg: (str) => re.bgBrown(str),
47
47
  statusBarText: (str) => re.white(str),
48
- highlight: (str) => re.invert(str),
48
+ highlight: (str) => re.bgYellow(re.black(str)),
49
49
  // For search results, etc.
50
- lineNumber: (str) => re.gray(str)
50
+ lineNumber: (str) => re.blue(str)
51
51
  },
52
52
  syntaxHighlightToggle: false,
53
53
  // Toggled state for syntax highlighting
@@ -91,7 +91,7 @@ function setupTheme(configTheme) {
91
91
  } else {
92
92
  state.theme = {
93
93
  text: (str) => re.black(str),
94
- statusBarBg: (str) => re.bgGray(str),
94
+ statusBarBg: (str) => re.bgBrown(str),
95
95
  statusBarText: (str) => re.white(str),
96
96
  highlight: (str) => re.bgCyan(re.black(str)),
97
97
  lineNumber: (str) => re.gray(str)
@@ -808,10 +808,10 @@ async function initializeEditorState(options) {
808
808
  state.theme = {
809
809
  // Reset theme based on config
810
810
  text: (str) => str,
811
- statusBarBg: (str) => re.bgGray(str),
811
+ statusBarBg: (str) => re.bgBrown(str),
812
812
  statusBarText: (str) => re.white(str),
813
- highlight: (str) => re.invert(str),
814
- lineNumber: (str) => re.gray(str)
813
+ highlight: (str) => re.bgYellow(re.black(str)),
814
+ lineNumber: (str) => re.blue(str)
815
815
  };
816
816
  setupTheme(state.editorConfig.theme);
817
817
  } catch (error) {
@@ -1,4 +1,4 @@
1
- import type { ConfirmPromptOptions } from "../../core-types.js";
1
+ import type { ConfirmPromptOptions } from "../../types.js";
2
2
  /**
3
3
  * Prompts the user with a yes/no question, returning a boolean based on their input.
4
4
  */
@@ -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,
@@ -1,4 +1,4 @@
1
- import type { InputPromptOptions } from "../../core-types.js";
1
+ import type { InputPromptOptions } from "../../types.js";
2
2
  /**
3
3
  * inputPrompt()
4
4
  *
@@ -1,14 +1,10 @@
1
1
  import { re } from "@reliverse/relico";
2
2
  import { isUnicodeSupported } from "@reliverse/runtime";
3
3
  import readline from "node:readline/promises";
4
- import {
5
- bar,
6
- msg,
7
- msgUndoAll
8
- } from "../msg-fmt/messages.js";
4
+ import { bar, msg, msgUndoAll } from "../msg-fmt/messages.js";
9
5
  import { deleteLastLine } from "../msg-fmt/terminal.js";
10
- import { completePrompt } from "../utils/prompt-end.js";
11
- import { streamText } from "../utils/stream-text.js";
6
+ import { completePrompt } from "../../utils/prompt-end.js";
7
+ import { streamText } from "../../utils/stream-text.js";
12
8
  const unicode = isUnicodeSupported();
13
9
  const S_MASK = unicode ? "\u258B" : "*";
14
10
  function getMaskChar(customMask) {
@@ -2,7 +2,7 @@ import type {
2
2
  Default,
3
3
  ParserArgv,
4
4
  ParserOptions,
5
- } from "~/libs/core/core-types.js";
5
+ } from "~/types.js";
6
6
 
7
7
  function toArr(any: any) {
8
8
  // biome-ignore lint/suspicious/noDoubleEquals: <explanation>
@@ -1,4 +1,4 @@
1
- import type { Resolvable } from "~/libs/core/core-types.js";
1
+ import type { Resolvable } from "~/types.js";
2
2
 
3
3
  export function toArray(val: any) {
4
4
  if (Array.isArray(val)) {
@@ -1,6 +1,6 @@
1
1
  import { kebabCase, camelCase } from "scule";
2
2
 
3
- import type { Arg, ArgsDef, ParsedArgs } from "~/libs/core/core-types.js";
3
+ import type { Arg, ArgsDef, ParsedArgs } from "~/types.js";
4
4
 
5
5
  import { parseRawArgs } from "./_parser.js";
6
6
  import { CLIError, toArray } from "./_utils.js";
@@ -3,7 +3,7 @@ import type {
3
3
  CommandContext,
4
4
  CommandDef,
5
5
  RunCommandOptions,
6
- } from "~/libs/core/core-types.js";
6
+ } from "~/types.js";
7
7
 
8
8
  import { CLIError, resolveValue } from "./_utils.js";
9
9
  import { parseArgs } from "./args.js";
@@ -1,6 +1,6 @@
1
1
  import { relinka } from "@reliverse/relinka";
2
2
 
3
- import type { ArgsDef, CommandDef } from "~/libs/core/core-types.js";
3
+ import type { ArgsDef, CommandDef } from "~/types.js";
4
4
 
5
5
  import { CLIError } from "./_utils.js";
6
6
  import { resolveSubCommand, runCommand } from "./command.js";
@@ -1,7 +1,7 @@
1
1
  import { re } from "@reliverse/relico";
2
2
  import { relinka } from "@reliverse/relinka";
3
3
 
4
- import type { ArgsDef, CommandDef } from "~/libs/core/core-types.js";
4
+ import type { ArgsDef, CommandDef } from "~/types.js";
5
5
 
6
6
  import { formatLineColumns, resolveValue } from "./_utils.js";
7
7
  import { resolveArgs } from "./args.js";
@@ -0,0 +1,133 @@
1
+ import type { ReliArgParserOptions } from "@reliverse/reliarg";
2
+ type InvalidDefaultError<O extends readonly string[]> = {
3
+ __error__: "Default value(s) must be a subset of options";
4
+ options: O;
5
+ };
6
+ type EmptyArgs = Record<string, never>;
7
+ type BaseArgProps = {
8
+ description?: string;
9
+ required?: boolean;
10
+ };
11
+ type PositionalArgDefinition = {
12
+ type: "positional";
13
+ default?: string;
14
+ } & BaseArgProps;
15
+ type BooleanArgDefinition = {
16
+ type: "boolean";
17
+ default?: boolean;
18
+ } & BaseArgProps;
19
+ type StringArgDefinition = {
20
+ type: "string";
21
+ default?: string;
22
+ } & BaseArgProps;
23
+ type NumberArgDefinition = {
24
+ type: "number";
25
+ default?: number;
26
+ } & BaseArgProps;
27
+ type ArrayArgDefinition = {
28
+ type: "array";
29
+ default?: string | readonly string[];
30
+ options: readonly string[];
31
+ } & BaseArgProps;
32
+ export type ArgDefinition = PositionalArgDefinition | BooleanArgDefinition | StringArgDefinition | NumberArgDefinition | ArrayArgDefinition;
33
+ export type ArgDefinitions = Record<string, ArgDefinition>;
34
+ type CommandMeta = {
35
+ name: string;
36
+ version?: string;
37
+ description?: string;
38
+ hidden?: boolean;
39
+ aliases?: string[];
40
+ };
41
+ /**
42
+ * A subcommand can be either:
43
+ * 1) A string path to a module with a default export of type Command.
44
+ * 2) A lazy import function returning a Promise that resolves to
45
+ * { default: Command<any> } or directly to a Command instance.
46
+ */
47
+ type SubCommandSpec = string | (() => Promise<{
48
+ default: Command<any>;
49
+ } | Command<any>>);
50
+ export type SubCommandsMap = Record<string, SubCommandSpec>;
51
+ type CommandContext<ARGS> = {
52
+ args: ARGS;
53
+ raw: string[];
54
+ };
55
+ type CommandRun<ARGS> = (ctx: CommandContext<ARGS>) => void | Promise<void>;
56
+ type DefineCommandOptions<A extends ArgDefinitions = EmptyArgs> = {
57
+ meta?: CommandMeta;
58
+ args?: A;
59
+ run?: CommandRun<InferArgTypes<A>>;
60
+ subCommands?: SubCommandsMap;
61
+ setup?: () => void | Promise<void>;
62
+ cleanup?: () => void | Promise<void>;
63
+ };
64
+ export type Command<A extends ArgDefinitions = EmptyArgs> = {
65
+ meta?: CommandMeta;
66
+ args: A;
67
+ run?: CommandRun<InferArgTypes<A>>;
68
+ subCommands?: SubCommandsMap;
69
+ setup?: () => void | Promise<void>;
70
+ cleanup?: () => void | Promise<void>;
71
+ };
72
+ export type InferArgTypes<A extends ArgDefinitions> = {
73
+ [K in keyof A]: A[K] extends PositionalArgDefinition ? string : A[K] extends BooleanArgDefinition ? boolean : A[K] extends StringArgDefinition ? string : A[K] extends NumberArgDefinition ? number : A[K] extends {
74
+ type: "array";
75
+ options: infer O extends readonly string[];
76
+ } ? O[number][] : never;
77
+ };
78
+ type ValidateArrayDefaults<A extends ArgDefinitions> = {
79
+ [K in keyof A]: A[K] extends {
80
+ type: "array";
81
+ options: infer O extends readonly string[];
82
+ default?: infer D;
83
+ } ? D extends undefined ? A[K] : D extends O[number] ? A[K] : D extends readonly (infer E)[] ? E extends O[number] ? A[K] : Omit<A[K], "default"> & {
84
+ default: InvalidDefaultError<O>;
85
+ } : Omit<A[K], "default"> & {
86
+ default: InvalidDefaultError<O>;
87
+ } : A[K];
88
+ };
89
+ export type FileBasedCmdsOptions = {
90
+ enable: boolean;
91
+ cmdsRootPath: string;
92
+ };
93
+ /**
94
+ * Defines a command with metadata, argument definitions,
95
+ * an execution function, and (optional) subCommands.
96
+ */
97
+ export declare function defineCommand<A extends ArgDefinitions = EmptyArgs>(options: DefineCommandOptions<A>): Command<A>;
98
+ /**
99
+ * Show usage for a given command.
100
+ */
101
+ export declare function showUsage<A extends ArgDefinitions>(command: Command<A>, parserOptions?: ReliArgParserOptions & {
102
+ fileBasedCmds?: FileBasedCmdsOptions;
103
+ autoExit?: boolean;
104
+ metaSettings?: {
105
+ showDescriptionOnMain?: boolean;
106
+ };
107
+ }, displayNotFoundMessage?: boolean): Promise<void>;
108
+ /**
109
+ * Primary entry point to run a command. This function supports:
110
+ *
111
+ * - File-based Subcommands: scanning for subcommands within a given commands root.
112
+ * - SubCommands defined within the command object.
113
+ * - Standard flags like --help, --version, and --debug.
114
+ *
115
+ * This function passes along remaining arguments to subcommand runners to ensure
116
+ * consistent parsing.
117
+ */
118
+ export declare function runMain<A extends ArgDefinitions = EmptyArgs>(command: Command<A>, parserOptions?: ReliArgParserOptions & {
119
+ fileBasedCmds?: FileBasedCmdsOptions;
120
+ autoExit?: boolean;
121
+ metaSettings?: {
122
+ showDescriptionOnMain?: boolean;
123
+ };
124
+ }): Promise<void>;
125
+ /**
126
+ * Helper to define argument definitions with improved type inference
127
+ * for IntelliSense and validation for array defaults against options.
128
+ *
129
+ * **Note:** For array types, use `as const` on the `options` array to enable
130
+ * precise default value validation (e.g., `options: ["a", "b"] as const`).
131
+ */
132
+ export declare function defineArgs<A extends ArgDefinitions>(args: A & ValidateArrayDefaults<A>): A;
133
+ export {};