@h3ravel/musket 0.2.3 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -156,10 +156,3 @@ The H3ravel framework is open-sourced software licensed under the [MIT license](
156
156
  [lini]: https://img.shields.io/github/license/h3ravel/framework
157
157
  [tel]: https://github.com/h3ravel/framework/actions/workflows/test.yml
158
158
  [tei]: https://github.com/h3ravel/framework/actions/workflows/test.yml/badge.svg
159
-
160
- ````
161
-
162
- ```
163
-
164
- ```
165
- ````
package/dist/index.cjs CHANGED
@@ -224,6 +224,40 @@ var Command = class {
224
224
  __h3ravel_shared.Logger.debug(message);
225
225
  return this;
226
226
  }
227
+ /**
228
+ * Prompt the user with the given question, accept their input, and
229
+ * then return the user's input back to your command.
230
+ */
231
+ ask(message, def) {
232
+ return __h3ravel_shared.Prompts.ask(message, def);
233
+ }
234
+ /**
235
+ * Allows users to pick from a predefined set of choices when asked a question.
236
+ */
237
+ choice(message, choices, defaultIndex) {
238
+ return __h3ravel_shared.Prompts.choice(message, choices, defaultIndex);
239
+ }
240
+ /**
241
+ * Ask the user for a simple "yes or no" confirmation. By default, this method returns `false`.
242
+ * However, if the user enters y or yes in response to the prompt, the method would return `true`.
243
+ */
244
+ confirm(message, def) {
245
+ return __h3ravel_shared.Prompts.confirm(message, def);
246
+ }
247
+ /**
248
+ * Prompt the user with the given question, accept their input which will
249
+ * not be visible to them as they type in the console, and then return the user's input back to your command.
250
+ */
251
+ secret(message, mask) {
252
+ return __h3ravel_shared.Prompts.secret(message, mask);
253
+ }
254
+ /**
255
+ * Provide auto-completion for possible choices. The user can still provide any
256
+ * answer, regardless of the auto-completion hints.
257
+ */
258
+ anticipate(message, source, def) {
259
+ return __h3ravel_shared.Prompts.anticipate(message, source, def);
260
+ }
227
261
  };
228
262
 
229
263
  //#endregion
package/dist/index.d.cts CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as commander0 from "commander";
2
2
  import { Argument, Command as Command$1 } from "commander";
3
+ import { ChoiceOrSeparatorArray, Choices } from "@h3ravel/shared";
3
4
  import { Options } from "tsdown";
4
5
  import { XGeneric } from "@h3ravel/support";
5
6
 
@@ -242,6 +243,80 @@ declare class Command {
242
243
  * Log a debug message
243
244
  */
244
245
  debug(message: string | string[]): this;
246
+ /**
247
+ * Prompt the user with the given question, accept their input, and
248
+ * then return the user's input back to your command.
249
+ */
250
+ ask(
251
+ /**
252
+ * Message to dislpay
253
+ */
254
+ message: string,
255
+ /**
256
+ * The default value
257
+ */
258
+ def?: string | undefined): Promise<string>;
259
+ /**
260
+ * Allows users to pick from a predefined set of choices when asked a question.
261
+ */
262
+ choice(
263
+ /**
264
+ * Message to dislpay
265
+ */
266
+ message: string,
267
+ /**
268
+ * The choices available to the user
269
+ */
270
+ choices: Choices,
271
+ /**
272
+ * Item index front of which the cursor will initially appear
273
+ */
274
+ defaultIndex?: number): Promise<string>;
275
+ /**
276
+ * Ask the user for a simple "yes or no" confirmation. By default, this method returns `false`.
277
+ * However, if the user enters y or yes in response to the prompt, the method would return `true`.
278
+ */
279
+ confirm(
280
+ /**
281
+ * Message to dislpay
282
+ */
283
+ message: string,
284
+ /**
285
+ * The default value
286
+ */
287
+ def?: boolean | undefined): Promise<boolean>;
288
+ /**
289
+ * Prompt the user with the given question, accept their input which will
290
+ * not be visible to them as they type in the console, and then return the user's input back to your command.
291
+ */
292
+ secret(
293
+ /**
294
+ * Message to dislpay
295
+ */
296
+ message: string,
297
+ /**
298
+ * Mask the user input
299
+ *
300
+ * @default true
301
+ */
302
+ mask?: string | boolean): Promise<string>;
303
+ /**
304
+ * Provide auto-completion for possible choices. The user can still provide any
305
+ * answer, regardless of the auto-completion hints.
306
+ */
307
+ anticipate(
308
+ /**
309
+ * Message to dislpay
310
+ */
311
+ message: string,
312
+ /**
313
+ * The source of completions
314
+ */
315
+ source: string[] | ((input?: string | undefined) => Promise<ChoiceOrSeparatorArray<any>>),
316
+ /**
317
+ * Set a default value
318
+ */
319
+ def?: string): Promise<any>;
245
320
  }
246
321
  //#endregion
247
322
  //#region src/Musket.d.ts
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { ChoiceOrSeparatorArray, Choices } from "@h3ravel/shared";
1
2
  import * as commander0 from "commander";
2
3
  import { Argument, Command as Command$1 } from "commander";
3
4
  import { Options } from "tsdown";
@@ -242,6 +243,80 @@ declare class Command {
242
243
  * Log a debug message
243
244
  */
244
245
  debug(message: string | string[]): this;
246
+ /**
247
+ * Prompt the user with the given question, accept their input, and
248
+ * then return the user's input back to your command.
249
+ */
250
+ ask(
251
+ /**
252
+ * Message to dislpay
253
+ */
254
+ message: string,
255
+ /**
256
+ * The default value
257
+ */
258
+ def?: string | undefined): Promise<string>;
259
+ /**
260
+ * Allows users to pick from a predefined set of choices when asked a question.
261
+ */
262
+ choice(
263
+ /**
264
+ * Message to dislpay
265
+ */
266
+ message: string,
267
+ /**
268
+ * The choices available to the user
269
+ */
270
+ choices: Choices,
271
+ /**
272
+ * Item index front of which the cursor will initially appear
273
+ */
274
+ defaultIndex?: number): Promise<string>;
275
+ /**
276
+ * Ask the user for a simple "yes or no" confirmation. By default, this method returns `false`.
277
+ * However, if the user enters y or yes in response to the prompt, the method would return `true`.
278
+ */
279
+ confirm(
280
+ /**
281
+ * Message to dislpay
282
+ */
283
+ message: string,
284
+ /**
285
+ * The default value
286
+ */
287
+ def?: boolean | undefined): Promise<boolean>;
288
+ /**
289
+ * Prompt the user with the given question, accept their input which will
290
+ * not be visible to them as they type in the console, and then return the user's input back to your command.
291
+ */
292
+ secret(
293
+ /**
294
+ * Message to dislpay
295
+ */
296
+ message: string,
297
+ /**
298
+ * Mask the user input
299
+ *
300
+ * @default true
301
+ */
302
+ mask?: string | boolean): Promise<string>;
303
+ /**
304
+ * Provide auto-completion for possible choices. The user can still provide any
305
+ * answer, regardless of the auto-completion hints.
306
+ */
307
+ anticipate(
308
+ /**
309
+ * Message to dislpay
310
+ */
311
+ message: string,
312
+ /**
313
+ * The source of completions
314
+ */
315
+ source: string[] | ((input?: string | undefined) => Promise<ChoiceOrSeparatorArray<any>>),
316
+ /**
317
+ * Set a default value
318
+ */
319
+ def?: string): Promise<any>;
245
320
  }
246
321
  //#endregion
247
322
  //#region src/Musket.d.ts
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { FileSystem, Logger } from "@h3ravel/shared";
1
+ import { FileSystem, Logger, Prompts } from "@h3ravel/shared";
2
2
  import { Argument, Option, program } from "commander";
3
3
  import { build } from "tsdown";
4
4
  import { glob } from "glob";
@@ -194,6 +194,40 @@ var Command = class {
194
194
  Logger.debug(message);
195
195
  return this;
196
196
  }
197
+ /**
198
+ * Prompt the user with the given question, accept their input, and
199
+ * then return the user's input back to your command.
200
+ */
201
+ ask(message, def) {
202
+ return Prompts.ask(message, def);
203
+ }
204
+ /**
205
+ * Allows users to pick from a predefined set of choices when asked a question.
206
+ */
207
+ choice(message, choices, defaultIndex) {
208
+ return Prompts.choice(message, choices, defaultIndex);
209
+ }
210
+ /**
211
+ * Ask the user for a simple "yes or no" confirmation. By default, this method returns `false`.
212
+ * However, if the user enters y or yes in response to the prompt, the method would return `true`.
213
+ */
214
+ confirm(message, def) {
215
+ return Prompts.confirm(message, def);
216
+ }
217
+ /**
218
+ * Prompt the user with the given question, accept their input which will
219
+ * not be visible to them as they type in the console, and then return the user's input back to your command.
220
+ */
221
+ secret(message, mask) {
222
+ return Prompts.secret(message, mask);
223
+ }
224
+ /**
225
+ * Provide auto-completion for possible choices. The user can still provide any
226
+ * answer, regardless of the auto-completion hints.
227
+ */
228
+ anticipate(message, source, def) {
229
+ return Prompts.anticipate(message, source, def);
230
+ }
197
231
  };
198
232
 
199
233
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@h3ravel/musket",
3
- "version": "0.2.3",
3
+ "version": "0.3.0",
4
4
  "description": "Musket CLI is a framework-agnostic CLI framework designed to allow you build artisan-like CLI apps and for use in the H3ravel framework.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -69,7 +69,7 @@
69
69
  "vitest": "^3.2.4"
70
70
  },
71
71
  "dependencies": {
72
- "@h3ravel/shared": "^0.22.2",
72
+ "@h3ravel/shared": "^0.23.1",
73
73
  "chalk": "^5.6.2",
74
74
  "commander": "^14.0.1",
75
75
  "dayjs": "^1.11.18",