@akterjs/cli 0.0.0-stage → 0.1.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 (108) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +47 -2
  3. package/dist/Argument-D81dqizB.mjs +57 -0
  4. package/dist/Array-B4kuTQeW.mjs +2323 -0
  5. package/dist/Boolean-kILIvmhE.mjs +26 -0
  6. package/dist/ChildProcess-BCIwxPGc.mjs +577 -0
  7. package/dist/CliError-Cf5xqkkj.mjs +633 -0
  8. package/dist/Command-Dzq9KM-h.mjs +5135 -0
  9. package/dist/Config-B6OND9WR.mjs +854 -0
  10. package/dist/Console-BKHUkH6a.mjs +141 -0
  11. package/dist/Data-CeCULr0-.mjs +251 -0
  12. package/dist/Digest-CBd3uv5B.mjs +348 -0
  13. package/dist/Duration-EH9Vy4U6.mjs +791 -0
  14. package/dist/Effect-CKFpqbmw.mjs +12911 -0
  15. package/dist/FileSystem-4pPcEb_i.mjs +1366 -0
  16. package/dist/HttpClientError-BUeMWx70.mjs +303 -0
  17. package/dist/HttpClientResponse-D5ZKICVV.mjs +855 -0
  18. package/dist/Match-CGPLZYrV.mjs +434 -0
  19. package/dist/MutableHashMap-f8nW8AJR.mjs +376 -0
  20. package/dist/MutableHashSet-_HI572Ya.mjs +155 -0
  21. package/dist/MutableRef-D4Qv592C.mjs +107 -0
  22. package/dist/Number-BvkRkfc-.mjs +137 -0
  23. package/dist/Option-DkxSnBhp.mjs +3967 -0
  24. package/dist/Order-C1JC991I.mjs +481 -0
  25. package/dist/Path-Djdv_eF5.mjs +130 -0
  26. package/dist/Queue-CO5UQ6os.mjs +1394 -0
  27. package/dist/Redacted-RkJrG5Me.mjs +160 -0
  28. package/dist/Ref-BIPOxJNH.mjs +267 -0
  29. package/dist/Runtime-BInIAwK3.mjs +297 -0
  30. package/dist/Schema-MiKt5K1v.mjs +10999 -0
  31. package/dist/SecureRandom-B_U4ysO3.mjs +279 -0
  32. package/dist/Semaphore-DOVJ4ZGS.mjs +177 -0
  33. package/dist/Stdio-KylmOBX_.mjs +74 -0
  34. package/dist/Stream-bK9QIETN.mjs +4012 -0
  35. package/dist/String-q5dcsVe4.mjs +351 -0
  36. package/dist/TerminalCapabilities-w_44MAca.mjs +1769 -0
  37. package/dist/WebCrypto-ZI_GNVlw.mjs +33 -0
  38. package/dist/actor-call.service-CGM_vD9u.mjs +1269 -0
  39. package/dist/actor-client.adapter-Coem7gF1.mjs +3691 -0
  40. package/dist/akter-program.config-C4cXx4Fr.mjs +7034 -0
  41. package/dist/akter.cli.mjs +5 -0
  42. package/dist/app-cli.config.mjs +49 -0
  43. package/dist/app-entry.pure.mjs +31 -0
  44. package/dist/archive/akter-archive.schema.mjs +65 -0
  45. package/dist/archive/akter-archive.service.mjs +309 -0
  46. package/dist/archive/archive-cli.config.mjs +45 -0
  47. package/dist/archive/archive-invalid.errors.mjs +5 -0
  48. package/dist/archive/archived-lineage.pure.mjs +13 -0
  49. package/dist/archive/tar.pure.mjs +291 -0
  50. package/dist/archive/zstd.adapter.mjs +46 -0
  51. package/dist/bench/bench-report.pure.mjs +120 -0
  52. package/dist/bench/bench-runner.pure.mjs +89 -0
  53. package/dist/bench/bench.service.mjs +301 -0
  54. package/dist/cli-runtime.layer-BqK2mmVL.mjs +1191 -0
  55. package/dist/cli-runtime.layer.mjs +1 -0
  56. package/dist/cloud-client.adapter-Cy1BjDbG.mjs +3186 -0
  57. package/dist/cloud-client.adapter-DOVMoYAj.mjs +304 -0
  58. package/dist/command/akter-commands.config.mjs +32 -0
  59. package/dist/command/akter-program.config.mjs +1 -0
  60. package/dist/credentials/credentials.service.mjs +226 -0
  61. package/dist/credentials/keychain.adapter.mjs +92 -0
  62. package/dist/credentials/login.config.mjs +251 -0
  63. package/dist/deploy/auth/api-attempt.service.mjs +30 -0
  64. package/dist/deploy/auth/token-refresh.errors.mjs +4 -0
  65. package/dist/deploy/build-bundle.adapter.mjs +133 -0
  66. package/dist/deploy/build-manifest.pure.mjs +44 -0
  67. package/dist/deploy/cloud-client.adapter.mjs +1 -0
  68. package/dist/deploy/cloud-url.pure.mjs +17 -0
  69. package/dist/deploy/deploy-failed.errors.mjs +17 -0
  70. package/dist/deploy/deploy.service.mjs +156 -0
  71. package/dist/deploy/request-failure.pure.mjs +87 -0
  72. package/dist/dev-runner.pure.mjs +30 -0
  73. package/dist/docs/doc-topics.pure.mjs +21 -0
  74. package/dist/docs/docs.config.mjs +1 -0
  75. package/dist/docs.config-_21Xi6HU.mjs +190 -0
  76. package/dist/export/actor-export.service.mjs +267 -0
  77. package/dist/export/export-failed.errors.mjs +4 -0
  78. package/dist/export/export-failure.pure.mjs +18 -0
  79. package/dist/export/ordered-lines.pure.mjs +43 -0
  80. package/dist/export/ranged-download.pure.mjs +66 -0
  81. package/dist/export/snapshot-download.pure.mjs +86 -0
  82. package/dist/history-runner.pure.mjs +186 -0
  83. package/dist/history-since.pure.mjs +17 -0
  84. package/dist/hosted-runtime.layer-Cx3IPsEd.mjs +16358 -0
  85. package/dist/local/environment-cli.config.mjs +90 -0
  86. package/dist/local/environment-runner.pure.mjs +75 -0
  87. package/dist/local/local-cli.config.mjs +159 -0
  88. package/dist/logs/log-follow.config.mjs +21 -0
  89. package/dist/logs/log-follow.service.mjs +87 -0
  90. package/dist/logs/log-lines.pure.mjs +44 -0
  91. package/dist/migrate-runner.pure.mjs +28 -0
  92. package/dist/operation-input.pure-CS9iUhqK.mjs +1383 -0
  93. package/dist/operation-registry.pure-DVC8EDgj.mjs +283 -0
  94. package/dist/registry/actor-call.service.mjs +1 -0
  95. package/dist/registry/actor-commands.config.mjs +127 -0
  96. package/dist/registry/actor-refusal.pure.mjs +34 -0
  97. package/dist/registry/approval.service.mjs +80 -0
  98. package/dist/registry/cloud-commands.config.mjs +151 -0
  99. package/dist/registry/cloud-served.pure.mjs +31 -0
  100. package/dist/registry/operation-call.service.mjs +262 -0
  101. package/dist/registry/operation-input.pure.mjs +1 -0
  102. package/dist/registry/operation-output.pure.mjs +91 -0
  103. package/dist/registry/served-command.config.mjs +57 -0
  104. package/dist/runner-exited.errors.mjs +10 -0
  105. package/dist/terminal/cli-exit.errors.mjs +38 -0
  106. package/dist/terminal/cli-failure.pure.mjs +31 -0
  107. package/dist/terminal/confirm.adapter.mjs +27 -0
  108. package/package.json +61 -3
@@ -0,0 +1,633 @@
1
+ import { qt as hasProperty } from "./Option-DkxSnBhp.mjs";
2
+ import { n as errorReported, t as errorExitCode } from "./Runtime-BInIAwK3.mjs";
3
+ import { F as String, Y as Union, an as optionalKey, d as Defect, in as optional, n as ArraySchema, x as Literal, z as TaggedError } from "./Schema-MiKt5K1v.mjs";
4
+ // ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/cli/CliError.js
5
+ /**
6
+ * Defines structured errors for the unstable CLI parser and runner.
7
+ *
8
+ * CLI errors describe problems such as unknown or duplicate flags, missing
9
+ * flags or arguments, unexpected positional arguments, invalid values, unknown
10
+ * subcommands, rejected input combinations, user handler failures, and
11
+ * requests to show command help. This module includes the `CliError` union,
12
+ * the `isCliError` guard, the `userMessage` annotation for rendering handler
13
+ * failures, schema-backed error classes with display messages, and the
14
+ * `NonShowHelpErrors` union used when parse or validation errors should be
15
+ * shown with help output.
16
+ *
17
+ * @stability unstable
18
+ * @since 4.0.0
19
+ */
20
+ /**
21
+ * @stability unstable
22
+ * @category type IDs
23
+ * @since 4.0.0
24
+ */
25
+ const TypeId = "~effect/cli/CliError";
26
+ /**
27
+ * Type guard to check if a value is a CLI error.
28
+ *
29
+ * **Example** (Checking CLI errors)
30
+ *
31
+ * ```ts import.meta.vitest
32
+ * import { Effect } from "effect"
33
+ * import { CliError } from "effect/cli"
34
+ *
35
+ * const error = new CliError.MissingOption({ option: "api-key" })
36
+ * const program = CliError.isCliError(error)
37
+ * ? Effect.succeed(error.message)
38
+ * : Effect.fail("Unknown error")
39
+ *
40
+ * await Effect.runPromise(program) // => "Missing required flag: --api-key"
41
+ * ```
42
+ *
43
+ * @stability unstable
44
+ * @category guards
45
+ * @since 4.0.0
46
+ */
47
+ const isCliError = (u) => hasProperty(u, TypeId);
48
+ /**
49
+ * Defines the runtime property key used to give an object error a user-facing
50
+ * message.
51
+ *
52
+ * **When to use**
53
+ *
54
+ * Use when a handler fails with a domain error that should be shown to the
55
+ * user without wrapping it in {@link UserError}.
56
+ *
57
+ * **Details**
58
+ *
59
+ * When a handler failure has a string `[CliError.userMessage]`, `Command.run`
60
+ * renders it with the installed formatter, sets `Runtime.errorReported` to
61
+ * `false`, and rethrows the original error, so its tag is preserved. The
62
+ * global `Error` interface declares this key as an optional string.
63
+ *
64
+ * **Example** (Rendering a tagged handler failure)
65
+ *
66
+ * ```ts import.meta.vitest
67
+ * import { Schema } from "effect"
68
+ * import { CliError } from "effect/cli"
69
+ *
70
+ * class Occupied extends Schema.TaggedError<Occupied>()("Occupied", {
71
+ * path: Schema.String
72
+ * }) {
73
+ * override get [CliError.userMessage]() {
74
+ * return `${this.path} already exists`
75
+ * }
76
+ * }
77
+ *
78
+ * const error = new Occupied({ path: "config.yaml" })
79
+ * CliError.getUserMessage(error) // => "config.yaml already exists"
80
+ * ```
81
+ *
82
+ * @see {@link getUserMessage} for reading the message stored under this key
83
+ *
84
+ * @stability unstable
85
+ * @category annotations
86
+ * @since 4.0.0
87
+ */
88
+ const userMessage = "~effect/cli/CliError/userMessage";
89
+ /**
90
+ * Reads the `CliError.userMessage` annotation from an error object, returning
91
+ * `undefined` when it is unset or not a string.
92
+ *
93
+ * @see {@link userMessage} for the annotation key this getter reads
94
+ *
95
+ * @stability unstable
96
+ * @category annotations
97
+ * @since 4.0.0
98
+ */
99
+ const getUserMessage = (error) => "~effect/cli/CliError/userMessage" in error && typeof error["~effect/cli/CliError/userMessage"] === "string" ? error[userMessage] : void 0;
100
+ /**
101
+ * Error thrown when an unrecognized option is encountered.
102
+ *
103
+ * **Example** (Creating unrecognized option errors)
104
+ *
105
+ * ```ts import.meta.vitest
106
+ * import { Effect } from "effect"
107
+ * import { CliError } from "effect/cli"
108
+ *
109
+ * // Creating an unrecognized option error
110
+ * const unrecognizedError = new CliError.UnrecognizedOption({
111
+ * option: "--unknown-flag",
112
+ * command: ["deploy", "production"],
113
+ * suggestions: ["--verbose", "--force"]
114
+ * })
115
+ *
116
+ * unrecognizedError._tag // => "UnrecognizedOption"
117
+ * unrecognizedError.option // => "--unknown-flag"
118
+ * unrecognizedError.command // => ["deploy", "production"]
119
+ *
120
+ * // In CLI parsing context
121
+ * const parseCommand = Effect.gen(function*() {
122
+ * // If parsing encounters unknown flag
123
+ * return yield* unrecognizedError
124
+ * })
125
+ *
126
+ * const parseError = await Effect.runPromise(Effect.flip(parseCommand))
127
+ * parseError._tag // => "UnrecognizedOption"
128
+ * ```
129
+ *
130
+ * @stability unstable
131
+ * @category errors
132
+ * @since 4.0.0
133
+ */
134
+ var UnrecognizedOption = class extends (/*#__PURE__*/ TaggedError(`${TypeId}/UnrecognizedOption`)("UnrecognizedOption", {
135
+ option: String,
136
+ command: /*#__PURE__*/ optional(/*#__PURE__*/ ArraySchema(String)),
137
+ suggestions: /*#__PURE__*/ ArraySchema(String)
138
+ })) {
139
+ /**
140
+ * Marks this value as a CLI parsing error for runtime guards.
141
+ *
142
+ * @stability unstable
143
+ * @since 4.0.0
144
+ */
145
+ [TypeId] = TypeId;
146
+ /**
147
+ * Formats the unrecognized option with command context and suggestions.
148
+ *
149
+ * @stability unstable
150
+ * @since 4.0.0
151
+ */
152
+ get message() {
153
+ const suggestionText = this.suggestions.length > 0 ? `\n\n Did you mean this?\n ${this.suggestions.join("\n ")}` : "";
154
+ return (this.command ? `Unrecognized flag: ${this.option} in command ${this.command.join(" ")}` : `Unrecognized flag: ${this.option}`) + suggestionText;
155
+ }
156
+ };
157
+ /**
158
+ * Error thrown when duplicate option names are detected between parent and child commands.
159
+ *
160
+ * **Example** (Creating duplicate option errors)
161
+ *
162
+ * ```ts import.meta.vitest
163
+ * import { CliError } from "effect/cli"
164
+ *
165
+ * const duplicateError = new CliError.DuplicateOption({
166
+ * option: "--verbose",
167
+ * parentCommand: "myapp",
168
+ * childCommand: "deploy"
169
+ * })
170
+ *
171
+ * duplicateError._tag // => "DuplicateOption"
172
+ * duplicateError.option // => "--verbose"
173
+ * duplicateError.parentCommand // => "myapp"
174
+ * duplicateError.childCommand // => "deploy"
175
+ * ```
176
+ *
177
+ * @stability unstable
178
+ * @category errors
179
+ * @since 4.0.0
180
+ */
181
+ var DuplicateOption = class extends (/*#__PURE__*/ TaggedError(`${TypeId}/DuplicateOption`)("DuplicateOption", {
182
+ option: String,
183
+ parentCommand: String,
184
+ childCommand: String
185
+ })) {
186
+ /**
187
+ * Marks this value as a CLI configuration error for runtime guards.
188
+ *
189
+ * @stability unstable
190
+ * @since 4.0.0
191
+ */
192
+ [TypeId] = TypeId;
193
+ /**
194
+ * Explains which parent and child commands define the duplicate option.
195
+ *
196
+ * @stability unstable
197
+ * @since 4.0.0
198
+ */
199
+ get message() {
200
+ return `Duplicate flag name "${this.option}" in parent command "${this.parentCommand}" and subcommand "${this.childCommand}". Parent will always claim this flag (Mode A semantics). Consider renaming one of them to avoid confusion.`;
201
+ }
202
+ };
203
+ /**
204
+ * Error thrown when a required option is missing.
205
+ *
206
+ * **Example** (Creating missing option errors)
207
+ *
208
+ * ```ts import.meta.vitest
209
+ * import { Effect } from "effect"
210
+ * import { CliError } from "effect/cli"
211
+ *
212
+ * const missingOptionError = new CliError.MissingOption({
213
+ * option: "api-key"
214
+ * })
215
+ *
216
+ * const details = [missingOptionError._tag, missingOptionError.option] // => ["MissingOption", "api-key"]
217
+ *
218
+ * // In validation context
219
+ * const validateRequiredOptions = (options: Record<string, string | undefined>) =>
220
+ * Effect.gen(function*() {
221
+ * const apiKey = options["api-key"]
222
+ * if (!apiKey) {
223
+ * return yield* missingOptionError
224
+ * }
225
+ * return apiKey
226
+ * })
227
+ *
228
+ * const validationError = await Effect.runPromise(Effect.flip(validateRequiredOptions({})))
229
+ * validationError._tag // => "MissingOption"
230
+ * ```
231
+ *
232
+ * @stability unstable
233
+ * @category errors
234
+ * @since 4.0.0
235
+ */
236
+ var MissingOption = class extends (/*#__PURE__*/ TaggedError(`${TypeId}/MissingOption`)("MissingOption", { option: String })) {
237
+ /**
238
+ * Marks this value as a missing CLI option error for runtime guards.
239
+ *
240
+ * @stability unstable
241
+ * @since 4.0.0
242
+ */
243
+ [TypeId] = TypeId;
244
+ /**
245
+ * Formats the missing required flag for display.
246
+ *
247
+ * @stability unstable
248
+ * @since 4.0.0
249
+ */
250
+ get message() {
251
+ return `Missing required flag: --${this.option}`;
252
+ }
253
+ };
254
+ /**
255
+ * Error thrown when a required positional argument is missing.
256
+ *
257
+ * **Example** (Creating missing argument errors)
258
+ *
259
+ * ```ts import.meta.vitest
260
+ * import { Effect } from "effect"
261
+ * import { CliError } from "effect/cli"
262
+ *
263
+ * const missingArgError = new CliError.MissingArgument({
264
+ * argument: "target"
265
+ * })
266
+ *
267
+ * const details = [missingArgError._tag, missingArgError.argument] // => ["MissingArgument", "target"]
268
+ *
269
+ * // In argument parsing
270
+ * const parseArguments = (args: Array<string>) =>
271
+ * Effect.gen(function*() {
272
+ * if (args.length === 0) {
273
+ * return yield* missingArgError
274
+ * }
275
+ * return args[0]
276
+ * })
277
+ *
278
+ * const parseError = await Effect.runPromise(Effect.flip(parseArguments([])))
279
+ * parseError._tag // => "MissingArgument"
280
+ * ```
281
+ *
282
+ * @stability unstable
283
+ * @category errors
284
+ * @since 4.0.0
285
+ */
286
+ var MissingArgument = class extends (/*#__PURE__*/ TaggedError(`${TypeId}/MissingArgument`)("MissingArgument", { argument: String })) {
287
+ /**
288
+ * Marks this value as a missing CLI argument error for runtime guards.
289
+ *
290
+ * @stability unstable
291
+ * @since 4.0.0
292
+ */
293
+ [TypeId] = TypeId;
294
+ /**
295
+ * Formats the missing required positional argument for display.
296
+ *
297
+ * @stability unstable
298
+ * @since 4.0.0
299
+ */
300
+ get message() {
301
+ return `Missing required argument: ${this.argument}`;
302
+ }
303
+ };
304
+ /**
305
+ * Error thrown when positional arguments remain after a command has parsed all
306
+ * of its parameters.
307
+ *
308
+ * **Example** (Reporting unexpected arguments)
309
+ *
310
+ * ```ts import.meta.vitest
311
+ * import { CliError } from "effect/cli"
312
+ *
313
+ * const error = new CliError.UnexpectedArgument({
314
+ * arguments: ["extra.txt"]
315
+ * })
316
+ *
317
+ * const details = [error._tag, error.arguments] // => ["UnexpectedArgument", ["extra.txt"]]
318
+ * ```
319
+ *
320
+ * @stability unstable
321
+ * @category errors
322
+ * @since 4.0.0
323
+ */
324
+ var UnexpectedArgument = class extends (/*#__PURE__*/ TaggedError(`${TypeId}/UnexpectedArgument`)("UnexpectedArgument", { arguments: /*#__PURE__*/ ArraySchema(String) })) {
325
+ /**
326
+ * Marks this value as an unexpected CLI argument error for runtime guards.
327
+ *
328
+ * @stability unstable
329
+ * @since 4.0.0
330
+ */
331
+ [TypeId] = TypeId;
332
+ /**
333
+ * Formats the unexpected positional arguments for display.
334
+ *
335
+ * @stability unstable
336
+ * @since 4.0.0
337
+ */
338
+ get message() {
339
+ return `Unexpected positional ${this.arguments.length === 1 ? "argument" : "arguments"}: ${this.arguments.map((value) => JSON.stringify(value)).join(", ")}`;
340
+ }
341
+ };
342
+ /**
343
+ * Error thrown when an option or argument value is invalid.
344
+ *
345
+ * **Example** (Creating invalid value errors)
346
+ *
347
+ * ```ts import.meta.vitest
348
+ * import { CliError } from "effect/cli"
349
+ *
350
+ * const invalidValueError = new CliError.InvalidValue({
351
+ * option: "port",
352
+ * value: "abc123",
353
+ * expected: "integer between 1 and 65535",
354
+ * kind: "flag"
355
+ * })
356
+ *
357
+ * invalidValueError._tag // => "InvalidValue"
358
+ * invalidValueError.kind // => "flag"
359
+ * invalidValueError.option // => "port"
360
+ * invalidValueError.value // => "abc123"
361
+ *
362
+ * // For positional arguments
363
+ * const invalidArgError = new CliError.InvalidValue({
364
+ * option: "count",
365
+ * value: "abc",
366
+ * expected: "integer",
367
+ * kind: "argument"
368
+ * })
369
+ *
370
+ * const details = [invalidArgError.kind, invalidArgError.option, invalidArgError.value] // => ["argument", "count", "abc"]
371
+ * ```
372
+ *
373
+ * @stability unstable
374
+ * @category errors
375
+ * @since 4.0.0
376
+ */
377
+ var InvalidValue = class extends (/*#__PURE__*/ TaggedError(`${TypeId}/InvalidValue`)("InvalidValue", {
378
+ option: String,
379
+ value: String,
380
+ expected: String,
381
+ kind: /*#__PURE__*/ Union([/*#__PURE__*/ Literal("flag"), /*#__PURE__*/ Literal("argument")])
382
+ })) {
383
+ /**
384
+ * Marks this value as an invalid CLI value error for runtime guards.
385
+ *
386
+ * @stability unstable
387
+ * @since 4.0.0
388
+ */
389
+ [TypeId] = TypeId;
390
+ /**
391
+ * Formats the invalid flag or argument value with the expected input.
392
+ *
393
+ * @stability unstable
394
+ * @since 4.0.0
395
+ */
396
+ get message() {
397
+ const expectation = this.expected.startsWith("Expected ") || this.expected.startsWith("Expected:") ? this.expected : `Expected: ${this.expected}`;
398
+ if (this.kind === "argument") return `Invalid value for argument <${this.option}>: "${this.value}". ${expectation}`;
399
+ if (this.value.length === 0) return `Missing value for flag --${this.option}. ${expectation}`;
400
+ return `Invalid value for flag --${this.option}: "${this.value}". ${expectation}`;
401
+ }
402
+ };
403
+ /**
404
+ * Error thrown when an unknown subcommand is encountered.
405
+ *
406
+ * **Example** (Creating unknown subcommand errors)
407
+ *
408
+ * ```ts import.meta.vitest
409
+ * import { Effect } from "effect"
410
+ * import { CliError } from "effect/cli"
411
+ *
412
+ * const unknownSubcommandError = new CliError.UnknownSubcommand({
413
+ * subcommand: "deplyo", // typo
414
+ * parent: ["myapp"],
415
+ * suggestions: ["deploy", "destroy"]
416
+ * })
417
+ *
418
+ * unknownSubcommandError._tag // => "UnknownSubcommand"
419
+ * unknownSubcommandError.subcommand // => "deplyo"
420
+ * unknownSubcommandError.parent // => ["myapp"]
421
+ *
422
+ * // In subcommand parsing
423
+ * const parseSubcommand = (subcommand: string) =>
424
+ * Effect.gen(function*() {
425
+ * const validCommands = ["deploy", "destroy", "status"]
426
+ * if (!validCommands.includes(subcommand)) {
427
+ * return yield* unknownSubcommandError
428
+ * }
429
+ * return subcommand
430
+ * })
431
+ *
432
+ * const parseError = await Effect.runPromise(Effect.flip(parseSubcommand("deplyo")))
433
+ * parseError._tag // => "UnknownSubcommand"
434
+ * ```
435
+ *
436
+ * @stability unstable
437
+ * @category errors
438
+ * @since 4.0.0
439
+ */
440
+ var UnknownSubcommand = class extends (/*#__PURE__*/ TaggedError(`${TypeId}/UnknownSubcommand`)("UnknownSubcommand", {
441
+ subcommand: String,
442
+ parent: /*#__PURE__*/ optional(/*#__PURE__*/ ArraySchema(String)),
443
+ suggestions: /*#__PURE__*/ ArraySchema(String)
444
+ })) {
445
+ /**
446
+ * Marks this value as an unknown CLI subcommand error for runtime guards.
447
+ *
448
+ * @stability unstable
449
+ * @since 4.0.0
450
+ */
451
+ [TypeId] = TypeId;
452
+ /**
453
+ * Formats the unknown subcommand with parent command context and suggestions.
454
+ *
455
+ * @stability unstable
456
+ * @since 4.0.0
457
+ */
458
+ get message() {
459
+ const suggestionText = this.suggestions.length > 0 ? `\n\n Did you mean this?\n ${this.suggestions.join("\n ")}` : "";
460
+ return this.parent ? `Unknown subcommand "${this.subcommand}" for "${this.parent.join(" ")}"${suggestionText}` : `Unknown subcommand "${this.subcommand}"${suggestionText}`;
461
+ }
462
+ };
463
+ /**
464
+ * Error for parsed input that fails a rule of your own, such as two flags
465
+ * that cannot be used together.
466
+ *
467
+ * **Details**
468
+ *
469
+ * Fail with it from `Command.validate`, `Flag.mapEffect` or
470
+ * `Argument.mapEffect`. The runner shows it with the command help, like any
471
+ * other parse error. Handlers report their own failures with `UserError`.
472
+ *
473
+ * **Example** (Rejecting a flag combination)
474
+ *
475
+ * ```ts import.meta.vitest
476
+ * import { CliError } from "effect/cli"
477
+ *
478
+ * const error = new CliError.ValidationError({
479
+ * message: "--use-api and --use-docker are mutually exclusive"
480
+ * })
481
+ *
482
+ * error._tag // => "ValidationError"
483
+ * error.message // => "--use-api and --use-docker are mutually exclusive"
484
+ * ```
485
+ *
486
+ * @stability unstable
487
+ * @category errors
488
+ * @since 4.1.0
489
+ */
490
+ var ValidationError = class extends (/*#__PURE__*/ TaggedError(`${TypeId}/ValidationError`)("ValidationError", { message: String })) {
491
+ /**
492
+ * Marks this value as a CLI validation error for runtime guards.
493
+ *
494
+ * @stability unstable
495
+ * @since 4.1.0
496
+ */
497
+ [TypeId] = TypeId;
498
+ };
499
+ /**
500
+ * Error wrapper for user handler failures in the CLI error channel.
501
+ *
502
+ * **Details**
503
+ *
504
+ * `userMessage` can provide safe, user-facing text independently of the
505
+ * underlying cause. When omitted or empty, `message` uses a non-empty string
506
+ * cause or `Error.message`, then falls back to `"An error occurred"`.
507
+ *
508
+ * **Example** (Wrapping user errors)
509
+ *
510
+ * ```ts import.meta.vitest
511
+ * import { Effect } from "effect"
512
+ * import { CliError } from "effect/cli"
513
+ *
514
+ * // Wrapping user errors
515
+ * const userError = new CliError.UserError({
516
+ * cause: new Error("Database connection failed for postgres://localhost"),
517
+ * userMessage: "Could not connect to the database"
518
+ * })
519
+ *
520
+ * // In command handler
521
+ * const deployCommand = Effect.gen(function*() {
522
+ * const result = yield* Effect.try({
523
+ * try: () => ({ deployed: true }),
524
+ * catch: (error) => new CliError.UserError({ cause: error })
525
+ * })
526
+ * return result
527
+ * })
528
+ *
529
+ * // In error handling
530
+ * const handleError = (error: CliError.CliError): Effect.Effect<number> => {
531
+ * if (error._tag === "UserError") {
532
+ * return Effect.succeed(1) // Exit code 1
533
+ * }
534
+ * return Effect.succeed(0)
535
+ * }
536
+ *
537
+ * await Effect.runPromise(deployCommand) // => { deployed: true }
538
+ * await Effect.runPromise(handleError(userError)) // => 1
539
+ * ```
540
+ *
541
+ * @stability unstable
542
+ * @category errors
543
+ * @since 4.0.0
544
+ */
545
+ var UserError = class extends (/*#__PURE__*/ TaggedError(`${TypeId}/UserError`)("UserError", {
546
+ cause: /*#__PURE__*/ Defect(),
547
+ userMessage: /*#__PURE__*/ optionalKey(String)
548
+ })) {
549
+ /**
550
+ * Marks this value as a user handler error for runtime guards.
551
+ *
552
+ * @stability unstable
553
+ * @since 4.0.0
554
+ */
555
+ [TypeId] = TypeId;
556
+ /**
557
+ * Controls whether the runtime logger should report this error. The CLI
558
+ * runner sets this to `false` after rendering the error itself.
559
+ *
560
+ * @stability unstable
561
+ * @since 4.0.0
562
+ */
563
+ [errorReported] = true;
564
+ /**
565
+ * Returns the explicit user-facing message or a safe fallback from `cause`.
566
+ *
567
+ * @stability unstable
568
+ * @since 4.0.0
569
+ */
570
+ get message() {
571
+ if (this.userMessage) return this.userMessage;
572
+ if (typeof this.cause === "string" && this.cause) return this.cause;
573
+ if (this.cause instanceof Error && this.cause.message) return this.cause.message;
574
+ return "An error occurred";
575
+ }
576
+ /**
577
+ * Exposes `message` as the user-facing message rendered by `Command.run`.
578
+ *
579
+ * @stability unstable
580
+ * @since 4.0.0
581
+ */
582
+ get [userMessage]() {
583
+ return this.message;
584
+ }
585
+ };
586
+ /**
587
+ * Schema for concrete CLI errors that can be reported together with help output.
588
+ *
589
+ * **Details**
590
+ *
591
+ * This excludes `ShowHelp` itself, allowing parse and validation errors to be
592
+ * stored in `ShowHelp.errors` without nesting another help-control value.
593
+ *
594
+ * @stability unstable
595
+ * @category schemas
596
+ * @since 4.0.0
597
+ */
598
+ const NonShowHelpErrors = /*#__PURE__*/ Union([
599
+ UnrecognizedOption,
600
+ DuplicateOption,
601
+ MissingOption,
602
+ MissingArgument,
603
+ UnexpectedArgument,
604
+ InvalidValue,
605
+ UnknownSubcommand,
606
+ ValidationError,
607
+ UserError
608
+ ]);
609
+ /**
610
+ * Error data requesting CLI help rendering for a command path.
611
+ *
612
+ * **Details**
613
+ *
614
+ * It is used for explicit help requests and for parse or validation failures
615
+ * that should be shown with help text. When `errors` is non-empty, the runtime
616
+ * exit code is `1`; otherwise it is `0`.
617
+ *
618
+ * @stability unstable
619
+ * @category errors
620
+ * @since 4.0.0
621
+ */
622
+ var ShowHelp = class extends (/*#__PURE__*/ TaggedError(`${TypeId}/ShowHelp`)("ShowHelp", {
623
+ commandPath: /*#__PURE__*/ ArraySchema(String),
624
+ errors: /*#__PURE__*/ ArraySchema(NonShowHelpErrors)
625
+ })) {
626
+ [TypeId] = TypeId;
627
+ [errorExitCode] = this.errors.length ? 1 : 0;
628
+ [errorReported] = false;
629
+ get message() {
630
+ return "Help requested";
631
+ }
632
+ };
633
+ export { ShowHelp as a, UnrecognizedOption as c, isCliError as d, MissingOption as i, UserError as l, InvalidValue as n, UnexpectedArgument as o, MissingArgument as r, UnknownSubcommand as s, DuplicateOption as t, getUserMessage as u };