@reliverse/rempts-core 1.6.1 → 2.3.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.
Files changed (155) hide show
  1. package/README.md +398 -102
  2. package/dist/cli.d.ts +32 -0
  3. package/dist/cli.js +731 -0
  4. package/dist/config-loader.d.ts +42 -0
  5. package/dist/config-loader.js +20 -0
  6. package/dist/config.d.ts +99 -0
  7. package/dist/config.js +188 -0
  8. package/dist/file-loader.d.ts +43 -0
  9. package/dist/file-loader.js +199 -0
  10. package/dist/global-flags.d.ts +36 -0
  11. package/dist/global-flags.js +36 -0
  12. package/dist/mod.d.ts +13 -0
  13. package/dist/mod.js +19 -0
  14. package/dist/parser.d.ts +6 -0
  15. package/dist/parser.js +137 -0
  16. package/dist/plugin/context.d.ts +13 -0
  17. package/dist/plugin/context.js +53 -0
  18. package/dist/plugin/create.d.ts +92 -0
  19. package/dist/plugin/create.js +61 -0
  20. package/dist/plugin/loader.d.ts +12 -0
  21. package/dist/plugin/loader.js +65 -0
  22. package/dist/plugin/manager.d.ts +53 -0
  23. package/dist/plugin/manager.js +135 -0
  24. package/dist/plugin/mod.d.ts +10 -0
  25. package/dist/plugin/mod.js +27 -0
  26. package/dist/plugin/store.d.ts +45 -0
  27. package/dist/plugin/store.js +60 -0
  28. package/dist/plugin/testing.d.ts +38 -0
  29. package/dist/plugin/testing.js +175 -0
  30. package/dist/plugin/types.d.ts +146 -0
  31. package/dist/tui/registry.d.ts +8 -0
  32. package/dist/tui/registry.js +10 -0
  33. package/dist/tui/types.d.ts +58 -0
  34. package/dist/tui/types.js +10 -0
  35. package/dist/types.d.ts +178 -0
  36. package/dist/types.js +25 -0
  37. package/dist/utils/logger.d.ts +10 -0
  38. package/dist/utils/logger.js +27 -0
  39. package/dist/utils/merge.d.ts +13 -0
  40. package/dist/utils/merge.js +25 -0
  41. package/dist/utils/mod.d.ts +6 -0
  42. package/dist/utils/mod.js +2 -0
  43. package/dist/utils/type-helpers.d.ts +41 -0
  44. package/dist/utils/type-helpers.js +0 -0
  45. package/dist/validation.d.ts +30 -0
  46. package/dist/validation.js +121 -0
  47. package/package.json +47 -44
  48. package/src/cli.ts +1049 -0
  49. package/src/config-loader.ts +71 -0
  50. package/src/config.ts +270 -0
  51. package/src/file-loader.ts +346 -0
  52. package/src/global-flags.ts +50 -0
  53. package/src/mod.ts +74 -0
  54. package/src/parser.ts +212 -0
  55. package/src/plugin/context.ts +88 -0
  56. package/src/plugin/create.ts +174 -0
  57. package/src/plugin/loader.ts +111 -0
  58. package/src/plugin/manager.ts +244 -0
  59. package/src/plugin/mod.ts +51 -0
  60. package/src/plugin/store.ts +124 -0
  61. package/src/plugin/testing.ts +236 -0
  62. package/src/plugin/types.ts +206 -0
  63. package/src/tui/registry.ts +22 -0
  64. package/src/tui/types.ts +79 -0
  65. package/src/types.ts +285 -0
  66. package/src/utils/logger.ts +43 -0
  67. package/src/utils/merge.ts +54 -0
  68. package/src/utils/mod.ts +7 -0
  69. package/src/utils/type-helpers.ts +151 -0
  70. package/src/validation.ts +177 -0
  71. package/LICENSE +0 -21
  72. package/bin/core-impl/anykey/anykey-mod.d.ts +0 -12
  73. package/bin/core-impl/anykey/anykey-mod.js +0 -125
  74. package/bin/core-impl/date/date.d.ts +0 -2
  75. package/bin/core-impl/date/date.js +0 -236
  76. package/bin/core-impl/editor/editor-mod.d.ts +0 -25
  77. package/bin/core-impl/editor/editor-mod.js +0 -896
  78. package/bin/core-impl/figures/figures-mod.d.ts +0 -233
  79. package/bin/core-impl/figures/figures-mod.js +0 -286
  80. package/bin/core-impl/figures/figures.test.d.ts +0 -1
  81. package/bin/core-impl/figures/figures.test.js +0 -474
  82. package/bin/core-impl/input/confirm-prompt.d.ts +0 -5
  83. package/bin/core-impl/input/confirm-prompt.js +0 -173
  84. package/bin/core-impl/input/input-prompt.d.ts +0 -16
  85. package/bin/core-impl/input/input-prompt.js +0 -370
  86. package/bin/core-impl/launcher/_parser.d.ts +0 -2
  87. package/bin/core-impl/launcher/_parser.js +0 -122
  88. package/bin/core-impl/launcher/_utils.d.ts +0 -8
  89. package/bin/core-impl/launcher/_utils.js +0 -29
  90. package/bin/core-impl/launcher/args.d.ts +0 -3
  91. package/bin/core-impl/launcher/args.js +0 -89
  92. package/bin/core-impl/launcher/command.d.ts +0 -8
  93. package/bin/core-impl/launcher/command.js +0 -68
  94. package/bin/core-impl/launcher/launcher-mod.d.ts +0 -8
  95. package/bin/core-impl/launcher/launcher-mod.js +0 -34
  96. package/bin/core-impl/launcher/usage.d.ts +0 -3
  97. package/bin/core-impl/launcher/usage.js +0 -104
  98. package/bin/core-impl/msg-fmt/colors.d.ts +0 -30
  99. package/bin/core-impl/msg-fmt/colors.js +0 -42
  100. package/bin/core-impl/msg-fmt/logger.d.ts +0 -17
  101. package/bin/core-impl/msg-fmt/logger.js +0 -106
  102. package/bin/core-impl/msg-fmt/mapping.d.ts +0 -3
  103. package/bin/core-impl/msg-fmt/mapping.js +0 -49
  104. package/bin/core-impl/msg-fmt/messages.d.ts +0 -35
  105. package/bin/core-impl/msg-fmt/messages.js +0 -314
  106. package/bin/core-impl/msg-fmt/terminal.d.ts +0 -15
  107. package/bin/core-impl/msg-fmt/terminal.js +0 -59
  108. package/bin/core-impl/msg-fmt/variants.d.ts +0 -11
  109. package/bin/core-impl/msg-fmt/variants.js +0 -52
  110. package/bin/core-impl/next-steps/next-steps.d.ts +0 -14
  111. package/bin/core-impl/next-steps/next-steps.js +0 -24
  112. package/bin/core-impl/number/number-mod.d.ts +0 -28
  113. package/bin/core-impl/number/number-mod.js +0 -197
  114. package/bin/core-impl/results/results.d.ts +0 -7
  115. package/bin/core-impl/results/results.js +0 -27
  116. package/bin/core-impl/select/multiselect-prompt.d.ts +0 -2
  117. package/bin/core-impl/select/multiselect-prompt.js +0 -341
  118. package/bin/core-impl/select/nummultiselect-prompt.d.ts +0 -6
  119. package/bin/core-impl/select/nummultiselect-prompt.js +0 -105
  120. package/bin/core-impl/select/numselect-prompt.d.ts +0 -7
  121. package/bin/core-impl/select/numselect-prompt.js +0 -115
  122. package/bin/core-impl/select/select-prompt.d.ts +0 -33
  123. package/bin/core-impl/select/select-prompt.js +0 -302
  124. package/bin/core-impl/select/toggle-prompt.d.ts +0 -5
  125. package/bin/core-impl/select/toggle-prompt.js +0 -208
  126. package/bin/core-impl/st-end/end.d.ts +0 -2
  127. package/bin/core-impl/st-end/end.js +0 -42
  128. package/bin/core-impl/st-end/start.d.ts +0 -17
  129. package/bin/core-impl/st-end/start.js +0 -66
  130. package/bin/core-impl/task/progress.d.ts +0 -2
  131. package/bin/core-impl/task/progress.js +0 -57
  132. package/bin/core-impl/task/spinner.d.ts +0 -15
  133. package/bin/core-impl/task/spinner.js +0 -110
  134. package/bin/core-impl/utils/colorize.d.ts +0 -2
  135. package/bin/core-impl/utils/colorize.js +0 -134
  136. package/bin/core-impl/utils/errors.d.ts +0 -1
  137. package/bin/core-impl/utils/errors.js +0 -15
  138. package/bin/core-impl/utils/prevent.d.ts +0 -10
  139. package/bin/core-impl/utils/prevent.js +0 -69
  140. package/bin/core-impl/utils/prompt-end.d.ts +0 -8
  141. package/bin/core-impl/utils/prompt-end.js +0 -33
  142. package/bin/core-impl/utils/stream-text.d.ts +0 -18
  143. package/bin/core-impl/utils/stream-text.js +0 -136
  144. package/bin/core-impl/utils/system.d.ts +0 -6
  145. package/bin/core-impl/utils/system.js +0 -7
  146. package/bin/core-impl/utils/validate.d.ts +0 -22
  147. package/bin/core-impl/utils/validate.js +0 -17
  148. package/bin/core-impl/visual/animate/animate.d.ts +0 -14
  149. package/bin/core-impl/visual/animate/animate.js +0 -64
  150. package/bin/core-impl/visual/ascii-art/ascii-art.d.ts +0 -6
  151. package/bin/core-impl/visual/ascii-art/ascii-art.js +0 -12
  152. package/bin/core-types.d.ts +0 -434
  153. package/bin/main.d.ts +0 -41
  154. package/bin/main.js +0 -96
  155. /package/{bin/core-types.js → dist/plugin/types.js} +0 -0
package/README.md CHANGED
@@ -1,102 +1,398 @@
1
- # @reliverse/prompts
2
-
3
- [💖 GitHub Sponsors](https://github.com/sponsors/blefnk) [💬 Discord](https://discord.gg/3GawfWfAPe) • [📦 NPM](https://npmjs.com/package/@reliverse/prompts) • [📚 Docs](https://docs.reliverse.org/reliverse/prompts) • [✨ GitHub](https://github.com/reliverse/prompts)
4
-
5
- **@reliverse/prompts** is your modern, type-safe toolkit for building delightful CLI experiences. It's fast, flexible, and built with developer joy in mind. Forget the clutter — this is how CLI should feel.
6
-
7
- ## ⚡ Why It Rocks
8
-
9
- - ✨ **TypeScript-first** — fully typed prompts and helpers, with great DX
10
- - 🔧 **Flexible Prompt Types** — input, password, select, multiselect, confirm, toggle, number, spinner, and more
11
- - 🧠 **Smart validation** — works with Zod, TypeBox, or your own validators
12
- - 🌈 **Accessible & Adaptive** — meets WCAG AA, handles terminal resizing & color contrast
13
- - 🧯 **Crash-resistant** — gracefully exits on Ctrl+C or unexpected input
14
- - 🎨 **Custom theming** make it match your CLI style
15
- - 🚀 **Zero boilerplate** focus on the logic, not the wiring
16
-
17
- ## 🛠️ Install
18
-
19
- ```bash
20
- bun add @reliverse/prompts
21
- # or npm, pnpm, yarn
22
- ```
23
-
24
- Make sure you have [Bun](https://bun.sh), [Node.js](https://nodejs.org), and [Git](https://git-scm.com/downloads) installed.
25
-
26
- ## 🧪 Try It Out (Playground Mode)
27
-
28
- Wanna test drive before integrating? Clone the repo and run:
29
-
30
- ```bash
31
- git clone https://github.com/reliverse/prompts.git
32
- cd prompts
33
- bun i
34
- bun dev
35
- ```
36
-
37
- Then open `examples/launcher.ts` and explore different prompts.
38
-
39
- ![example](./examples/main.png)
40
-
41
- ## 🧩 Example Usage
42
-
43
- ```ts
44
- import {
45
- startPrompt, // Initialize prompt session (optional)
46
- inputPrompt, // Ask for user input
47
- } from "@reliverse/prompts";
48
-
49
- await startPrompt({
50
- clearConsole: true,
51
- titleColor: "inverse",
52
- packageName: "@reliverse/cli",
53
- packageVersion: "1.0.0",
54
- });
55
-
56
- const username = await inputPrompt({
57
- id: "username",
58
- title: "Welcome!",
59
- content: "What's your name?",
60
- });
61
-
62
- console.log(`Hey there, ${username}!`);
63
- ```
64
-
65
- > 🔎 You can also use `selectPrompt`, `multiselectPrompt`, `confirmPrompt`, `numberPrompt`, `spinnerPrompt`, and more.
66
-
67
- ## 🧠 Bonus Goodies
68
-
69
- - ⚙️ **Built-in argument parsing** parse CLI args without a separate lib
70
- - 🧪 **Unit-test friendly** prompts can be mocked/stubbed
71
- - 📚 **Minimal API surface** — easy to learn, hard to outgrow
72
- - 💅 **Custom styles** — tweak colors, formats, and transitions
73
-
74
- ## 🔍 Why not Inquirer or Clack?
75
-
76
- While we love other tools, `@reliverse/prompts` was built for:
77
-
78
- - Dev-first ergonomics
79
- - Fully typed workflows
80
- - Configurable theming
81
- - Better crash handling & UX polish
82
-
83
- [See feature comparison →](https://docs.reliverse.org/reliverse/prompts/#prompts-library-comparison)
84
-
85
- ## 💡 Contributing
86
-
87
- Wanna improve prompts or add something cool? PRs welcome!
88
- This project favors functional programming over OOP — no classes, just clean, composable logic.
89
-
90
- Open a PR or discussion on [GitHub](https://github.com/reliverse/prompts).
91
-
92
- ## 🙏 Shoutout
93
-
94
- This wouldn't exist without these gems:
95
-
96
- - [sboudrias/inquirer.js](https://github.com/sboudrias/inquirer.js)
97
- - [unjs/citty](https://github.com/unjs/citty)
98
- - [lukeed/mri](https://github.com/lukeed/mri)
99
-
100
- ## 📄 License
101
-
102
- 💖 MIT © 2025 [blefnk Nazar Kornienko](https://github.com/blefnk)
1
+ # rempts-core
2
+
3
+ The minimal, type-safe CLI framework for Bun.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ bun add rempts-core
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import { defineCommand, option } from '@reliverse/rempts-core'
15
+ import { type } from 'arktype'
16
+
17
+ export default defineCommand({
18
+ name: 'greet',
19
+ description: 'A friendly greeting',
20
+ options: {
21
+ name: option(
22
+ type("string", ">0"),
23
+ { description: 'Name to greet', short: 'n' }
24
+ ),
25
+ excited: option(
26
+ type("boolean", "=", false),
27
+ { description: 'Add excitement', short: 'e' }
28
+ )
29
+ },
30
+ handler: async ({ flags }) => {
31
+ const greeting = `Hello, ${flags.name}${flags.excited ? '!' : '.'}`
32
+ console.log(greeting)
33
+ }
34
+ })
35
+ ```
36
+
37
+ ## Features
38
+
39
+ - 🚀 **Type-safe** - Full TypeScript support with automatic type inference
40
+ - ⚡ **Fast** - Powered by Bun's native speed
41
+ - 📦 **Zero config** - Works out of the box with sensible defaults
42
+ - 🎯 **Minimal API** - Learn once, use everywhere
43
+ - 🔌 **Extensible** - Plugin system for custom functionality
44
+ - 🧪 **Testable** - First-class testing utilities included
45
+
46
+ ## Core Concepts
47
+
48
+ ### Commands
49
+
50
+ Define commands with automatic type inference:
51
+
52
+ ```typescript
53
+ import { defineCommand } from '@reliverse/rempts-core'
54
+
55
+ export default defineCommand({
56
+ name: 'build',
57
+ description: 'Build the project',
58
+ handler: async () => {
59
+ console.log('Building...')
60
+ }
61
+ })
62
+ ```
63
+
64
+ ### Options
65
+
66
+ Use the `option` helper with Standard Schema validation:
67
+
68
+ ```typescript
69
+ import { defineCommand, option } from '@reliverse/rempts-core'
70
+ import { type } from 'arktype'
71
+
72
+ export default defineCommand({
73
+ name: 'deploy',
74
+ options: {
75
+ env: option(
76
+ type("'dev'|'staging'|'prod'"),
77
+ { description: 'Target environment' }
78
+ ),
79
+ force: option(
80
+ type("boolean", "=", false),
81
+ { description: 'Force deployment', short: 'f' }
82
+ )
83
+ },
84
+ handler: async ({ flags }) => {
85
+ // TypeScript knows:
86
+ // flags.env is 'dev' | 'staging' | 'prod'
87
+ // flags.force is boolean
88
+ }
89
+ })
90
+ ```
91
+
92
+ ### Multi-Command CLIs
93
+
94
+ Create complex CLIs with multiple commands:
95
+
96
+ ```typescript
97
+ import { createCLI } from '@reliverse/rempts-core'
98
+ import build from './commands/build'
99
+ import deploy from './commands/deploy'
100
+ import test from './commands/test'
101
+
102
+ const cli = createCLI({
103
+ name: 'my-tool',
104
+ version: '1.0.0',
105
+ description: 'My awesome CLI tool',
106
+ commands: [build, deploy, test]
107
+ })
108
+
109
+ await cli.run()
110
+ ```
111
+
112
+ ## API Reference
113
+
114
+ ### `defineCommand(config)`
115
+
116
+ Creates a command definition with full type inference.
117
+
118
+ ### `option(schema, config)`
119
+
120
+ Creates a typed option with schema validation.
121
+
122
+ ### `createCLI(config)`
123
+
124
+ Creates a multi-command CLI application.
125
+
126
+ ### `defineConfig(config)`
127
+
128
+ Defines shared configuration for your CLI.
129
+
130
+ ## Plugin System
131
+
132
+ Rempts provides a powerful plugin system with compile-time type safety:
133
+
134
+ ### Basic Plugin
135
+
136
+ ```typescript
137
+ import { RemptsPlugin, createPlugin } from '@reliverse/rempts-core'
138
+
139
+ interface MyPluginStore {
140
+ apiKey: string
141
+ isAuthenticated: boolean
142
+ }
143
+
144
+ const myPlugin: RemptsPlugin<MyPluginStore> = {
145
+ name: 'my-plugin',
146
+ version: '1.0.0',
147
+
148
+ // Define the plugin's store
149
+ store: {
150
+ apiKey: '',
151
+ isAuthenticated: false
152
+ },
153
+
154
+ // Lifecycle hooks
155
+ setup(context) {
156
+ // One-time initialization
157
+ context.updateConfig({ customField: 'value' })
158
+ },
159
+
160
+ configResolved(config) {
161
+ // Called after all configuration is resolved
162
+ },
163
+
164
+ beforeCommand(context) {
165
+ // Called before each command - context.store is type-safe!
166
+ context.store.apiKey = process.env.API_KEY || ''
167
+ context.store.isAuthenticated = !!context.store.apiKey
168
+ },
169
+
170
+ afterCommand(context) {
171
+ // Called after each command with results
172
+ if (context.error) {
173
+ console.error('Command failed:', context.error)
174
+ }
175
+ }
176
+ }
177
+ ```
178
+
179
+ ### Plugin Factory
180
+
181
+ Use `createPlugin` for better ergonomics:
182
+
183
+ ```typescript
184
+ import { createPlugin } from '@reliverse/rempts-core'
185
+
186
+ export const authPlugin = createPlugin((options: AuthOptions) => {
187
+ return {
188
+ name: 'auth-plugin',
189
+ store: {
190
+ token: '',
191
+ user: null as User | null
192
+ },
193
+ async beforeCommand(context) {
194
+ const token = await loadToken()
195
+ context.store.token = token
196
+ context.store.user = await fetchUser(token)
197
+ }
198
+ }
199
+ })
200
+ ```
201
+
202
+ ### Using Plugins with Type Safety
203
+
204
+ ```typescript
205
+ const cli = await createCLI({
206
+ name: 'my-cli',
207
+ version: '1.0.0',
208
+ plugins: [
209
+ authPlugin({ provider: 'github' }),
210
+ myPlugin
211
+ ]
212
+ })
213
+
214
+ // In your command files (e.g., cmds/deploy/cmd.ts), the store is fully typed!
215
+ // cmds/deploy/cmd.ts
216
+ import { defineCommand } from '@reliverse/rempts-core'
217
+
218
+ export default defineCommand({
219
+ name: 'deploy',
220
+ handler: async ({ context }) => {
221
+ // TypeScript knows about all plugin stores!
222
+ if (!context?.store.isAuthenticated) {
223
+ throw new Error('Not authenticated')
224
+ }
225
+ console.log(`Deploying as ${context.store.user?.name}`)
226
+ }
227
+ })
228
+ ```
229
+
230
+ ### Plugin Development Utilities
231
+
232
+ Rempts provides utilities for plugin development and testing:
233
+
234
+ ```typescript
235
+ import {
236
+ createTestPlugin,
237
+ composePlugins,
238
+ createMockPluginContext,
239
+ testPluginHooks,
240
+ assertPluginBehavior
241
+ } from '@reliverse/rempts-core/plugin'
242
+
243
+ // Create a test plugin
244
+ const testPlugin = createTestPlugin(
245
+ { count: 0, message: '' },
246
+ {
247
+ beforeCommand(context) {
248
+ context.store.count++
249
+ console.log(`Count: ${context.store.count}`)
250
+ }
251
+ }
252
+ )
253
+
254
+ // Compose multiple plugins
255
+ const composedPlugin = composePlugins(
256
+ authPlugin({ provider: 'github' }),
257
+ loggingPlugin({ level: 'debug' }),
258
+ metricsPlugin({ enabled: true })
259
+ )
260
+
261
+ // Test plugin behavior
262
+ const results = await testPluginHooks(testPlugin, {
263
+ config: { name: 'test-cli', version: '1.0.0' },
264
+ store: { count: 0, message: 'test' }
265
+ })
266
+
267
+ assertPluginBehavior(results, {
268
+ beforeCommandShouldSucceed: true
269
+ })
270
+ ```
271
+
272
+ ### Module Augmentation
273
+
274
+ Plugins can extend Rempts's interfaces:
275
+
276
+ ```typescript
277
+ declare module '@reliverse/rempts-core' {
278
+ interface EnvironmentInfo {
279
+ isCI: boolean
280
+ ciProvider?: string
281
+ }
282
+ }
283
+ ```
284
+
285
+ ## Runtime Validation
286
+
287
+ Rempts provides runtime validation utilities for dynamic type checking:
288
+
289
+ ```typescript
290
+ import {
291
+ validateValue,
292
+ validateValues,
293
+ isValueOfType,
294
+ createValidator,
295
+ createBatchValidator
296
+ } from '@reliverse/rempts-core'
297
+
298
+ // Validate a single value
299
+ const result = await validateValue(
300
+ 'hello',
301
+ type("string", ">0"),
302
+ { option: 'message', command: 'greet' }
303
+ )
304
+
305
+ // Validate multiple values
306
+ const validated = await validateValues(
307
+ { name: 'John', age: 25 },
308
+ {
309
+ name: type("string"),
310
+ age: type("number")
311
+ },
312
+ 'user'
313
+ )
314
+
315
+ // Check value types
316
+ if (isValueOfType(value, 'string')) {
317
+ console.log('Value is a string')
318
+ }
319
+
320
+ // Create reusable validators
321
+ const nameValidator = createValidator(type("string", ">0"))
322
+ const userValidator = createBatchValidator({
323
+ name: type("string"),
324
+ age: type("number")
325
+ })
326
+ ```
327
+
328
+ ## Type Utilities
329
+
330
+ Rempts exports advanced TypeScript type utilities for complex type manipulation:
331
+
332
+ ```typescript
333
+ import {
334
+ UnionToIntersection,
335
+ MergeAll,
336
+ Expand,
337
+ DeepPartial,
338
+ Constrain,
339
+ NonEmptyArray,
340
+ IsNever,
341
+ IsAny,
342
+ IsUnknown
343
+ } from '@reliverse/rempts-core'
344
+ ```
345
+
346
+ ### Key Utilities
347
+
348
+ **UnionToIntersection** - Convert union types to intersection types:
349
+
350
+ ```typescript
351
+ type Example = UnionToIntersection<{ a: string } | { b: number }>
352
+ // Result: { a: string } & { b: number }
353
+ ```
354
+
355
+ **MergeAll** - Merge multiple object types:
356
+
357
+ ```typescript
358
+ type Example = MergeAll<[{ a: string }, { b: number }, { c: boolean }]>
359
+ // Result: { a: string; b: number; c: boolean }
360
+ ```
361
+
362
+ **Expand** - Expand complex types for better IntelliSense:
363
+
364
+ ```typescript
365
+ type Example = Expand<{ nested: { deep: { value: string } } }>
366
+ // Shows full type structure in IDE
367
+ ```
368
+
369
+ **DeepPartial** - Make all properties optional recursively:
370
+
371
+ ```typescript
372
+ type Example = DeepPartial<{ user: { name: string; age: number } }>
373
+ // Result: { user?: { name?: string; age?: number } }
374
+ ```
375
+
376
+ **Constrain** - Constrain types with fallback:
377
+
378
+ ```typescript
379
+ type Example = Constrain<string, 'a' | 'b' | 'c', 'a'>
380
+ // Result: 'a' | 'b' | 'c' (or 'a' if string doesn't match)
381
+ ```
382
+
383
+
384
+ ## Related Packages
385
+
386
+ - **[rempts-generator](/docs/packages/generator)** - Generate TypeScript definitions from commands
387
+ - **[rempts-utils](/docs/packages/utils)** - Shared utilities for CLI development
388
+ - **[rempts-test](/docs/packages/test)** - Testing utilities for CLI applications
389
+
390
+ ## Documentation
391
+
392
+ - [Getting Started](/docs/getting-started) - Step-by-step tutorial
393
+ - [Type Generation Guide](/docs/guides/type-generation) - Learn about code generation
394
+ - [API Reference](/docs/api) - Complete API documentation
395
+
396
+ ## License
397
+
398
+ MIT © blefnk
package/dist/cli.d.ts ADDED
@@ -0,0 +1,32 @@
1
+ import type { MergePluginStores, Plugin } from "./plugin/types.js";
2
+ import type { CLI, RemptsConfig } from "./types.js";
3
+ export declare function createApp<TPlugins extends readonly Plugin[] = [], TDefaultCommand extends string | undefined = undefined>(options?: {
4
+ /**
5
+ * CLI configuration override
6
+ */
7
+ config?: Partial<RemptsConfig> & {
8
+ plugins?: TPlugins;
9
+ };
10
+ /**
11
+ * Default command to run when no arguments are provided
12
+ */
13
+ defaultCommand?: TDefaultCommand;
14
+ /**
15
+ * Whether to auto-initialize commands from config
16
+ * @default true
17
+ */
18
+ autoInit?: boolean;
19
+ /**
20
+ * Custom config directory (overrides --cwd detection)
21
+ */
22
+ configDir?: string;
23
+ /**
24
+ * Entry file path (e.g., import.meta.path or __filename)
25
+ * If not provided, will be auto-detected from call stack
26
+ * Commands directory will be <entry-file-dir>/cmds
27
+ */
28
+ entryFile?: string;
29
+ }): Promise<CLI<MergePluginStores<TPlugins>>>;
30
+ export declare function createCLI<TPlugins extends readonly Plugin[] = []>(configOverride?: Partial<RemptsConfig> & {
31
+ plugins?: TPlugins;
32
+ }, entryFile?: string): Promise<CLI<MergePluginStores<TPlugins>>>;