effect 4.0.0-beta.85 → 4.0.0-beta.86
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/dist/ChannelSchema.d.ts +8 -8
- package/dist/ChannelSchema.d.ts.map +1 -1
- package/dist/Config.d.ts +2 -2
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js +10 -3
- package/dist/Config.js.map +1 -1
- package/dist/Cron.d.ts.map +1 -1
- package/dist/Cron.js +4 -0
- package/dist/Cron.js.map +1 -1
- package/dist/Schema.d.ts +745 -393
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +90 -64
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +20 -29
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaParser.d.ts +24 -24
- package/dist/SchemaParser.d.ts.map +1 -1
- package/dist/SchemaParser.js +43 -39
- package/dist/SchemaParser.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts +300 -300
- package/dist/internal/effect.js +6 -7
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/matcher.js +0 -2
- package/dist/internal/matcher.js.map +1 -1
- package/dist/internal/schema/representation.js +1 -5
- package/dist/internal/schema/representation.js.map +1 -1
- package/dist/internal/schema/schema.js.map +1 -1
- package/dist/testing/TestSchema.d.ts +9 -9
- package/dist/testing/TestSchema.d.ts.map +1 -1
- package/dist/testing/TestSchema.js +3 -2
- package/dist/testing/TestSchema.js.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.d.ts +2 -2
- package/dist/unstable/ai/AnthropicStructuredOutput.d.ts.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/Chat.d.ts +1 -1
- package/dist/unstable/ai/Chat.d.ts.map +1 -1
- package/dist/unstable/ai/LanguageModel.d.ts +4 -4
- package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
- package/dist/unstable/ai/McpSchema.d.ts +13 -6
- package/dist/unstable/ai/McpSchema.d.ts.map +1 -1
- package/dist/unstable/ai/McpSchema.js.map +1 -1
- package/dist/unstable/ai/McpServer.d.ts +4 -4
- package/dist/unstable/ai/McpServer.d.ts.map +1 -1
- package/dist/unstable/ai/McpServer.js.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.d.ts +2 -2
- package/dist/unstable/ai/OpenAiStructuredOutput.d.ts.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/Response.d.ts +2 -2
- package/dist/unstable/ai/Response.d.ts.map +1 -1
- package/dist/unstable/ai/Response.js.map +1 -1
- package/dist/unstable/ai/Tool.d.ts +26 -26
- package/dist/unstable/ai/Tool.d.ts.map +1 -1
- package/dist/unstable/ai/Tool.js.map +1 -1
- package/dist/unstable/cli/Argument.d.ts +8 -7
- package/dist/unstable/cli/Argument.d.ts.map +1 -1
- package/dist/unstable/cli/Argument.js.map +1 -1
- package/dist/unstable/cli/Flag.d.ts +8 -7
- package/dist/unstable/cli/Flag.d.ts.map +1 -1
- package/dist/unstable/cli/Flag.js.map +1 -1
- package/dist/unstable/cli/Param.d.ts +1806 -168
- package/dist/unstable/cli/Param.d.ts.map +1 -1
- package/dist/unstable/cli/Param.js +0 -70
- package/dist/unstable/cli/Param.js.map +1 -1
- package/dist/unstable/cli/Primitive.d.ts +3 -4
- package/dist/unstable/cli/Primitive.d.ts.map +1 -1
- package/dist/unstable/cli/Primitive.js.map +1 -1
- package/dist/unstable/cli/internal/ansi.d.ts.map +1 -1
- package/dist/unstable/cli/internal/ansi.js +0 -22
- package/dist/unstable/cli/internal/ansi.js.map +1 -1
- package/dist/unstable/cli/internal/config.d.ts +48 -0
- package/dist/unstable/cli/internal/config.d.ts.map +1 -1
- package/dist/unstable/cli/internal/config.js +0 -6
- package/dist/unstable/cli/internal/config.js.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts +3 -3
- package/dist/unstable/cluster/Reply.d.ts +2 -2
- package/dist/unstable/cluster/Reply.d.ts.map +1 -1
- package/dist/unstable/cluster/Reply.js.map +1 -1
- package/dist/unstable/devtools/DevToolsSchema.js.map +1 -1
- package/dist/unstable/encoding/Msgpack.d.ts +6 -6
- package/dist/unstable/encoding/Msgpack.d.ts.map +1 -1
- package/dist/unstable/encoding/Msgpack.js.map +1 -1
- package/dist/unstable/encoding/Ndjson.d.ts +8 -8
- package/dist/unstable/encoding/Ndjson.d.ts.map +1 -1
- package/dist/unstable/encoding/Sse.d.ts +1 -1
- package/dist/unstable/encoding/Sse.d.ts.map +1 -1
- package/dist/unstable/encoding/Sse.js.map +1 -1
- package/dist/unstable/eventlog/EventLogMessage.d.ts +22 -22
- package/dist/unstable/eventlog/EventLogMessage.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogRemote.d.ts +15 -15
- package/dist/unstable/http/HttpBody.d.ts +1 -1
- package/dist/unstable/http/HttpBody.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientRequest.d.ts +1 -1
- package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpIncomingMessage.d.ts +1 -1
- package/dist/unstable/http/HttpIncomingMessage.d.ts.map +1 -1
- package/dist/unstable/http/HttpIncomingMessage.js.map +1 -1
- package/dist/unstable/http/HttpMiddleware.d.ts.map +1 -1
- package/dist/unstable/http/HttpMiddleware.js +12 -3
- package/dist/unstable/http/HttpMiddleware.js.map +1 -1
- package/dist/unstable/httpapi/HttpApi.d.ts +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.d.ts +2 -2
- package/dist/unstable/httpapi/HttpApiClient.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts +32 -32
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiSchema.d.ts +13 -6
- package/dist/unstable/httpapi/HttpApiSchema.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiSchema.js +0 -13
- package/dist/unstable/httpapi/HttpApiSchema.js.map +1 -1
- package/dist/unstable/httpapi/OpenApi.js.map +1 -1
- package/dist/unstable/observability/internal/otlpProtobuf.js +0 -68
- package/dist/unstable/observability/internal/otlpProtobuf.js.map +1 -1
- package/dist/unstable/observability/internal/protobuf.js +0 -28
- package/dist/unstable/observability/internal/protobuf.js.map +1 -1
- package/dist/unstable/persistence/KeyValueStore.d.ts +2 -2
- package/dist/unstable/persistence/KeyValueStore.d.ts.map +1 -1
- package/dist/unstable/persistence/KeyValueStore.js.map +1 -1
- package/dist/unstable/persistence/Persistable.d.ts +6 -6
- package/dist/unstable/persistence/Persistable.d.ts.map +1 -1
- package/dist/unstable/persistence/PersistedQueue.d.ts +3 -3
- package/dist/unstable/persistence/PersistedQueue.d.ts.map +1 -1
- package/dist/unstable/persistence/PersistedQueue.js.map +1 -1
- package/dist/unstable/persistence/Persistence.d.ts +5 -5
- package/dist/unstable/persistence/Persistence.d.ts.map +1 -1
- package/dist/unstable/reactivity/AsyncResult.d.ts +2 -2
- package/dist/unstable/reactivity/AsyncResult.d.ts.map +1 -1
- package/dist/unstable/reactivity/Atom.d.ts +1 -1
- package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.d.ts +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.d.ts.map +1 -1
- package/dist/unstable/rpc/Rpc.d.ts +3 -4
- package/dist/unstable/rpc/Rpc.d.ts.map +1 -1
- package/dist/unstable/rpc/Rpc.js +1 -1
- package/dist/unstable/rpc/Rpc.js.map +1 -1
- package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcClient.js +25 -4
- package/dist/unstable/rpc/RpcClient.js.map +1 -1
- package/dist/unstable/rpc/RpcMessage.d.ts +7 -0
- package/dist/unstable/rpc/RpcMessage.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcMessage.js +20 -0
- package/dist/unstable/rpc/RpcMessage.js.map +1 -1
- package/dist/unstable/rpc/RpcMiddleware.d.ts +2 -2
- package/dist/unstable/rpc/RpcMiddleware.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSchema.d.ts +10 -3
- package/dist/unstable/rpc/RpcSchema.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSchema.js.map +1 -1
- package/dist/unstable/rpc/RpcWorker.d.ts +3 -3
- package/dist/unstable/rpc/RpcWorker.d.ts.map +1 -1
- package/dist/unstable/schema/Model.d.ts +2 -2
- package/dist/unstable/schema/Model.d.ts.map +1 -1
- package/dist/unstable/schema/Model.js.map +1 -1
- package/dist/unstable/schema/VariantSchema.d.ts +16 -2
- package/dist/unstable/schema/VariantSchema.d.ts.map +1 -1
- package/dist/unstable/schema/VariantSchema.js.map +1 -1
- package/dist/unstable/sql/SqlConnection.d.ts +1 -0
- package/dist/unstable/sql/SqlConnection.d.ts.map +1 -1
- package/dist/unstable/sql/SqlConnection.js.map +1 -1
- package/dist/unstable/sql/SqlModel.js.map +1 -1
- package/dist/unstable/sql/SqlResolver.d.ts +4 -4
- package/dist/unstable/sql/SqlResolver.d.ts.map +1 -1
- package/dist/unstable/sql/SqlResolver.js.map +1 -1
- package/dist/unstable/sql/SqlSchema.d.ts +5 -5
- package/dist/unstable/sql/SqlSchema.d.ts.map +1 -1
- package/dist/unstable/sql/Statement.d.ts +1 -0
- package/dist/unstable/sql/Statement.d.ts.map +1 -1
- package/dist/unstable/sql/Statement.js +3 -0
- package/dist/unstable/sql/Statement.js.map +1 -1
- package/dist/unstable/workflow/Activity.d.ts +2 -2
- package/dist/unstable/workflow/Activity.d.ts.map +1 -1
- package/dist/unstable/workflow/DurableDeferred.d.ts +18 -18
- package/dist/unstable/workflow/DurableDeferred.d.ts.map +1 -1
- package/dist/unstable/workflow/Workflow.d.ts +3 -3
- package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
- package/dist/unstable/workflow/Workflow.js.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.d.ts +3 -3
- package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/ChannelSchema.ts +9 -9
- package/src/Config.ts +12 -5
- package/src/Cron.ts +4 -0
- package/src/Schema.ts +963 -688
- package/src/SchemaAST.ts +25 -35
- package/src/SchemaParser.ts +85 -77
- package/src/internal/effect.ts +6 -22
- package/src/internal/matcher.ts +0 -5
- package/src/internal/schema/arbitrary.ts +1 -1
- package/src/internal/schema/representation.ts +1 -5
- package/src/internal/schema/schema.ts +1 -1
- package/src/testing/TestSchema.ts +14 -13
- package/src/unstable/ai/AnthropicStructuredOutput.ts +2 -2
- package/src/unstable/ai/Chat.ts +1 -1
- package/src/unstable/ai/LanguageModel.ts +7 -7
- package/src/unstable/ai/McpSchema.ts +16 -14
- package/src/unstable/ai/McpServer.ts +7 -7
- package/src/unstable/ai/OpenAiStructuredOutput.ts +2 -2
- package/src/unstable/ai/Response.ts +9 -5
- package/src/unstable/ai/Tool.ts +49 -47
- package/src/unstable/cli/Argument.ts +9 -8
- package/src/unstable/cli/Flag.ts +9 -8
- package/src/unstable/cli/Param.ts +6 -146
- package/src/unstable/cli/Primitive.ts +5 -6
- package/src/unstable/cli/internal/ansi.ts +0 -33
- package/src/unstable/cli/internal/config.ts +0 -8
- package/src/unstable/cli/internal/parser.ts +2 -2
- package/src/unstable/cluster/MessageStorage.ts +1 -1
- package/src/unstable/cluster/Reply.ts +6 -2
- package/src/unstable/devtools/DevToolsSchema.ts +1 -1
- package/src/unstable/encoding/Msgpack.ts +9 -7
- package/src/unstable/encoding/Ndjson.ts +10 -10
- package/src/unstable/encoding/Sse.ts +1 -1
- package/src/unstable/eventlog/Event.ts +3 -3
- package/src/unstable/http/HttpBody.ts +1 -1
- package/src/unstable/http/HttpClientRequest.ts +1 -1
- package/src/unstable/http/HttpIncomingMessage.ts +1 -1
- package/src/unstable/http/HttpMiddleware.ts +12 -3
- package/src/unstable/httpapi/HttpApi.ts +1 -1
- package/src/unstable/httpapi/HttpApiBuilder.ts +9 -5
- package/src/unstable/httpapi/HttpApiClient.ts +10 -10
- package/src/unstable/httpapi/HttpApiEndpoint.ts +45 -33
- package/src/unstable/httpapi/HttpApiMiddleware.ts +2 -2
- package/src/unstable/httpapi/HttpApiSchema.ts +16 -43
- package/src/unstable/httpapi/OpenApi.ts +5 -5
- package/src/unstable/observability/internal/otlpProtobuf.ts +0 -75
- package/src/unstable/observability/internal/protobuf.ts +0 -42
- package/src/unstable/persistence/KeyValueStore.ts +2 -2
- package/src/unstable/persistence/Persistable.ts +7 -7
- package/src/unstable/persistence/PersistedQueue.ts +3 -3
- package/src/unstable/persistence/Persistence.ts +5 -5
- package/src/unstable/reactivity/AsyncResult.ts +4 -4
- package/src/unstable/reactivity/Atom.ts +1 -1
- package/src/unstable/reactivity/AtomHttpApi.ts +1 -1
- package/src/unstable/rpc/Rpc.ts +7 -8
- package/src/unstable/rpc/RpcClient.ts +26 -4
- package/src/unstable/rpc/RpcMessage.ts +19 -0
- package/src/unstable/rpc/RpcMiddleware.ts +2 -2
- package/src/unstable/rpc/RpcSchema.ts +12 -9
- package/src/unstable/rpc/RpcWorker.ts +3 -3
- package/src/unstable/schema/Model.ts +2 -2
- package/src/unstable/schema/VariantSchema.ts +19 -17
- package/src/unstable/sql/SqlConnection.ts +5 -0
- package/src/unstable/sql/SqlModel.ts +2 -2
- package/src/unstable/sql/SqlResolver.ts +6 -6
- package/src/unstable/sql/SqlSchema.ts +5 -5
- package/src/unstable/sql/Statement.ts +11 -0
- package/src/unstable/workflow/Activity.ts +6 -6
- package/src/unstable/workflow/DurableDeferred.ts +33 -33
- package/src/unstable/workflow/Workflow.ts +5 -5
- package/src/unstable/workflow/WorkflowEngine.ts +10 -10
- package/dist/internal/concurrency.d.ts +0 -2
- package/dist/internal/concurrency.d.ts.map +0 -1
- package/dist/internal/concurrency.js +0 -29
- package/dist/internal/concurrency.js.map +0 -1
- package/src/internal/concurrency.ts +0 -52
|
@@ -12,14 +12,15 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import * as Config from "../../Config.ts";
|
|
14
14
|
import * as Effect from "../../Effect.ts";
|
|
15
|
-
import type * as FileSystem from "../../FileSystem.ts";
|
|
16
15
|
import * as Option from "../../Option.ts";
|
|
17
|
-
import type * as Path from "../../Path.ts";
|
|
18
16
|
import { type Pipeable } from "../../Pipeable.ts";
|
|
19
|
-
import
|
|
17
|
+
import * as Predicate from "../../Predicate.ts";
|
|
18
|
+
import type * as Redacted from "../../Redacted.ts";
|
|
19
|
+
import * as Result from "../../Result.ts";
|
|
20
|
+
import * as Schema from "../../Schema.ts";
|
|
20
21
|
import type { Covariant } from "../../Types.ts";
|
|
21
|
-
import type { ChildProcessSpawner } from "../process/ChildProcessSpawner.ts";
|
|
22
22
|
import * as CliError from "./CliError.ts";
|
|
23
|
+
import type { Environment } from "./Command.ts";
|
|
23
24
|
import * as Primitive from "./Primitive.ts";
|
|
24
25
|
import * as Prompt from "./Prompt.ts";
|
|
25
26
|
declare const TypeId = "~effect/cli/Param";
|
|
@@ -47,14 +48,6 @@ export interface Param<Kind extends ParamKind, out A> extends Param.Variance<A>
|
|
|
47
48
|
* @since 4.0.0
|
|
48
49
|
*/
|
|
49
50
|
export type ParamKind = "argument" | "flag";
|
|
50
|
-
/**
|
|
51
|
-
* Services that parameter parsing can require, such as filesystem, path,
|
|
52
|
-
* terminal, and child-process support.
|
|
53
|
-
*
|
|
54
|
-
* @category models
|
|
55
|
-
* @since 4.0.0
|
|
56
|
-
*/
|
|
57
|
-
export type Environment = FileSystem.FileSystem | Path.Path | Terminal.Terminal | ChildProcessSpawner;
|
|
58
51
|
/**
|
|
59
52
|
* Defines the kind discriminator for positional argument parameters.
|
|
60
53
|
*
|
|
@@ -239,6 +232,44 @@ export interface Variadic<Kind extends ParamKind, A> extends Param<Kind, Readonl
|
|
|
239
232
|
readonly min: Option.Option<number>;
|
|
240
233
|
readonly max: Option.Option<number>;
|
|
241
234
|
}
|
|
235
|
+
/**
|
|
236
|
+
* Type guard to check if a value is a Param.
|
|
237
|
+
*
|
|
238
|
+
* **Example** (Checking for params)
|
|
239
|
+
*
|
|
240
|
+
* ```ts
|
|
241
|
+
* import { Param } from "effect/unstable/cli"
|
|
242
|
+
*
|
|
243
|
+
* const maybeParam = Param.string(Param.flagKind, "name")
|
|
244
|
+
*
|
|
245
|
+
* if (Param.isParam(maybeParam)) {
|
|
246
|
+
* console.log("This is a Param")
|
|
247
|
+
* }
|
|
248
|
+
* ```
|
|
249
|
+
*
|
|
250
|
+
* @category refinements
|
|
251
|
+
* @since 4.0.0
|
|
252
|
+
*/
|
|
253
|
+
export declare const isParam: (u: unknown) => u is Param<any, ParamKind>;
|
|
254
|
+
/**
|
|
255
|
+
* Type guard to check if a param is a Single param (not composed).
|
|
256
|
+
*
|
|
257
|
+
* **Example** (Checking for single params)
|
|
258
|
+
*
|
|
259
|
+
* ```ts
|
|
260
|
+
* import { Param } from "effect/unstable/cli"
|
|
261
|
+
*
|
|
262
|
+
* const nameParam = Param.string(Param.flagKind, "name")
|
|
263
|
+
* const optionalParam = Param.optional(nameParam)
|
|
264
|
+
*
|
|
265
|
+
* console.log(Param.isSingle(nameParam)) // true
|
|
266
|
+
* console.log(Param.isSingle(optionalParam)) // false
|
|
267
|
+
* ```
|
|
268
|
+
*
|
|
269
|
+
* @category refinements
|
|
270
|
+
* @since 4.0.0
|
|
271
|
+
*/
|
|
272
|
+
export declare const isSingle: <const Kind extends ParamKind, A>(param: Param<Kind, A>) => param is Single<Kind, A>;
|
|
242
273
|
/**
|
|
243
274
|
* Constructs a leaf `Single` parameter from its kind, name, primitive parser,
|
|
244
275
|
* and optional help metadata.
|
|
@@ -261,199 +292,1806 @@ export declare const makeSingle: <const Kind extends ParamKind, A>(params: {
|
|
|
261
292
|
readonly hidden?: boolean | undefined;
|
|
262
293
|
}) => Single<Kind, A>;
|
|
263
294
|
/**
|
|
264
|
-
*
|
|
295
|
+
* Creates a string parameter.
|
|
265
296
|
*
|
|
266
|
-
* **
|
|
297
|
+
* **Example** (Creating string parameters)
|
|
267
298
|
*
|
|
268
|
-
*
|
|
269
|
-
*
|
|
270
|
-
* parsed value is wrapped in `Option.some()`.
|
|
299
|
+
* ```ts
|
|
300
|
+
* import { Param } from "effect/unstable/cli"
|
|
271
301
|
*
|
|
272
|
-
*
|
|
302
|
+
* // Create a string flag
|
|
303
|
+
* const nameFlag = Param.string(Param.flagKind, "name")
|
|
304
|
+
*
|
|
305
|
+
* // Create a string argument
|
|
306
|
+
* const fileArg = Param.string(Param.argumentKind, "file")
|
|
307
|
+
*
|
|
308
|
+
* // Usage in CLI: --name "John Doe" or as positional argument
|
|
309
|
+
* ```
|
|
310
|
+
*
|
|
311
|
+
* @category constructors
|
|
312
|
+
* @since 4.0.0
|
|
313
|
+
*/
|
|
314
|
+
export declare const string: <const Kind extends ParamKind>(kind: Kind, name: string) => Param<Kind, string>;
|
|
315
|
+
/**
|
|
316
|
+
* Creates a boolean parameter.
|
|
317
|
+
*
|
|
318
|
+
* **Example** (Creating boolean parameters)
|
|
273
319
|
*
|
|
274
320
|
* ```ts
|
|
275
321
|
* import { Param } from "effect/unstable/cli"
|
|
276
322
|
*
|
|
277
|
-
* // Create
|
|
278
|
-
*
|
|
279
|
-
*
|
|
280
|
-
*
|
|
323
|
+
* // Create a boolean flag
|
|
324
|
+
* const verboseFlag = Param.boolean(Param.flagKind, "verbose")
|
|
325
|
+
*
|
|
326
|
+
* // Create a boolean argument
|
|
327
|
+
* const enableArg = Param.boolean(Param.argumentKind, "enable")
|
|
328
|
+
*
|
|
329
|
+
* // Usage in CLI: --verbose (defaults to true when present, false when absent)
|
|
330
|
+
* // or as positional: true/false
|
|
281
331
|
* ```
|
|
282
332
|
*
|
|
283
|
-
* @category
|
|
333
|
+
* @category constructors
|
|
284
334
|
* @since 4.0.0
|
|
285
335
|
*/
|
|
286
|
-
export declare const
|
|
336
|
+
export declare const boolean: <const Kind extends ParamKind>(kind: Kind, name: string) => Param<Kind, boolean>;
|
|
287
337
|
/**
|
|
288
|
-
*
|
|
338
|
+
* Creates an integer parameter.
|
|
289
339
|
*
|
|
290
|
-
* **
|
|
340
|
+
* **Example** (Creating integer parameters)
|
|
291
341
|
*
|
|
292
|
-
*
|
|
293
|
-
*
|
|
342
|
+
* ```ts
|
|
343
|
+
* import { Param } from "effect/unstable/cli"
|
|
294
344
|
*
|
|
295
|
-
*
|
|
345
|
+
* // Create an integer flag
|
|
346
|
+
* const portFlag = Param.integer(Param.flagKind, "port")
|
|
296
347
|
*
|
|
297
|
-
*
|
|
298
|
-
*
|
|
348
|
+
* // Create an integer argument
|
|
349
|
+
* const countArg = Param.integer(Param.argumentKind, "count")
|
|
299
350
|
*
|
|
300
|
-
*
|
|
351
|
+
* // Usage in CLI: --port 8080 or as positional argument: 42
|
|
352
|
+
* ```
|
|
301
353
|
*
|
|
302
|
-
*
|
|
303
|
-
*
|
|
354
|
+
* @category constructors
|
|
355
|
+
* @since 4.0.0
|
|
356
|
+
*/
|
|
357
|
+
export declare const integer: <const Kind extends ParamKind>(kind: Kind, name: string) => Param<Kind, number>;
|
|
358
|
+
/**
|
|
359
|
+
* Creates a floating-point number parameter.
|
|
304
360
|
*
|
|
305
|
-
*
|
|
306
|
-
* @see {@link withFallbackPrompt} for prompting interactively when input is missing
|
|
361
|
+
* **Example** (Creating float parameters)
|
|
307
362
|
*
|
|
308
|
-
*
|
|
363
|
+
* ```ts
|
|
364
|
+
* import { Param } from "effect/unstable/cli"
|
|
365
|
+
*
|
|
366
|
+
* // Create a float flag
|
|
367
|
+
* const rateFlag = Param.float(Param.flagKind, "rate")
|
|
368
|
+
*
|
|
369
|
+
* // Create a float argument
|
|
370
|
+
* const thresholdArg = Param.float(Param.argumentKind, "threshold")
|
|
371
|
+
*
|
|
372
|
+
* // Usage in CLI: --rate 0.95 or as positional argument: 3.14159
|
|
373
|
+
* ```
|
|
374
|
+
*
|
|
375
|
+
* @category constructors
|
|
309
376
|
* @since 4.0.0
|
|
310
377
|
*/
|
|
311
|
-
export declare const
|
|
312
|
-
/**
|
|
313
|
-
* Adds a fallback config that is loaded when a required parameter is missing.
|
|
314
|
-
*
|
|
315
|
-
* **When to use**
|
|
316
|
-
*
|
|
317
|
-
* Use when you need config to provide a fallback source for required flags or
|
|
318
|
-
* arguments that are absent from CLI input.
|
|
319
|
-
*
|
|
320
|
-
* **Details**
|
|
321
|
-
*
|
|
322
|
-
* Provided CLI values win. Config is loaded only after a missing option or
|
|
323
|
-
* missing argument error.
|
|
324
|
-
*
|
|
325
|
-
* **Gotchas**
|
|
326
|
-
*
|
|
327
|
-
* Missing config preserves the original missing-parameter error. Config parse
|
|
328
|
-
* failure becomes `CliError.InvalidValue`.
|
|
329
|
-
*
|
|
330
|
-
* @see {@link withDefault} for a pure default value
|
|
331
|
-
* @see {@link withFallbackPrompt} for prompting interactively when input is missing
|
|
332
|
-
*
|
|
333
|
-
* @category combinators
|
|
334
|
-
* @since 4.0.0
|
|
335
|
-
*/
|
|
336
|
-
<B>(config: Config.Config<B>): <Kind extends ParamKind, A>(self: Param<Kind, A>) => Param<Kind, A | B>;
|
|
337
|
-
/**
|
|
338
|
-
* Adds a fallback config that is loaded when a required parameter is missing.
|
|
339
|
-
*
|
|
340
|
-
* **When to use**
|
|
341
|
-
*
|
|
342
|
-
* Use when you need config to provide a fallback source for required flags or
|
|
343
|
-
* arguments that are absent from CLI input.
|
|
344
|
-
*
|
|
345
|
-
* **Details**
|
|
346
|
-
*
|
|
347
|
-
* Provided CLI values win. Config is loaded only after a missing option or
|
|
348
|
-
* missing argument error.
|
|
349
|
-
*
|
|
350
|
-
* **Gotchas**
|
|
351
|
-
*
|
|
352
|
-
* Missing config preserves the original missing-parameter error. Config parse
|
|
353
|
-
* failure becomes `CliError.InvalidValue`.
|
|
354
|
-
*
|
|
355
|
-
* @see {@link withDefault} for a pure default value
|
|
356
|
-
* @see {@link withFallbackPrompt} for prompting interactively when input is missing
|
|
357
|
-
*
|
|
358
|
-
* @category combinators
|
|
359
|
-
* @since 4.0.0
|
|
360
|
-
*/
|
|
361
|
-
<Kind extends ParamKind, A, B>(self: Param<Kind, A>, config: Config.Config<B>): Param<Kind, A | B>;
|
|
362
|
-
};
|
|
378
|
+
export declare const float: <const Kind extends ParamKind>(kind: Kind, name: string) => Param<Kind, number>;
|
|
363
379
|
/**
|
|
364
|
-
*
|
|
380
|
+
* Creates a date parameter that parses ISO date strings.
|
|
365
381
|
*
|
|
366
|
-
* **
|
|
382
|
+
* **Example** (Creating date parameters)
|
|
367
383
|
*
|
|
368
|
-
*
|
|
369
|
-
*
|
|
384
|
+
* ```ts
|
|
385
|
+
* import { Param } from "effect/unstable/cli"
|
|
370
386
|
*
|
|
371
|
-
*
|
|
387
|
+
* // Create a date flag
|
|
388
|
+
* const startFlag = Param.date(Param.flagKind, "start-date")
|
|
372
389
|
*
|
|
373
|
-
*
|
|
374
|
-
*
|
|
390
|
+
* // Create a date argument
|
|
391
|
+
* const dueDateArg = Param.date(Param.argumentKind, "due-date")
|
|
375
392
|
*
|
|
376
|
-
*
|
|
393
|
+
* // Usage in CLI: --start-date "2023-12-25" or as positional: "2023-01-01"
|
|
394
|
+
* // Parses to JavaScript Date object
|
|
395
|
+
* ```
|
|
377
396
|
*
|
|
378
|
-
*
|
|
379
|
-
*
|
|
397
|
+
* @category constructors
|
|
398
|
+
* @since 4.0.0
|
|
399
|
+
*/
|
|
400
|
+
export declare const date: <const Kind extends ParamKind>(kind: Kind, name: string) => Param<Kind, Date>;
|
|
401
|
+
/**
|
|
402
|
+
* Constructs command-line params that represent a choice between several
|
|
403
|
+
* inputs. The input will be mapped to it's associated value during parsing.
|
|
380
404
|
*
|
|
381
|
-
*
|
|
382
|
-
* @see {@link withFallbackConfig} for loading a fallback from config
|
|
383
|
-
* @see {@link withDefault} for a pure default value
|
|
405
|
+
* **Example** (Creating valued choices)
|
|
384
406
|
*
|
|
385
|
-
*
|
|
407
|
+
* ```ts
|
|
408
|
+
* import { Param } from "effect/unstable/cli"
|
|
409
|
+
*
|
|
410
|
+
* type Animal = Dog | Cat
|
|
411
|
+
*
|
|
412
|
+
* interface Dog {
|
|
413
|
+
* readonly _tag: "Dog"
|
|
414
|
+
* }
|
|
415
|
+
*
|
|
416
|
+
* interface Cat {
|
|
417
|
+
* readonly _tag: "Cat"
|
|
418
|
+
* }
|
|
419
|
+
*
|
|
420
|
+
* const animal = Param.choiceWithValue(Param.flagKind, "animal", [
|
|
421
|
+
* ["dog", { _tag: "Dog" }],
|
|
422
|
+
* ["cat", { _tag: "Cat" }]
|
|
423
|
+
* ])
|
|
424
|
+
* ```
|
|
425
|
+
*
|
|
426
|
+
* @category constructors
|
|
386
427
|
* @since 4.0.0
|
|
387
428
|
*/
|
|
388
|
-
export declare const
|
|
389
|
-
/**
|
|
390
|
-
* Adds a fallback prompt that is shown when a required parameter is missing.
|
|
391
|
-
*
|
|
392
|
-
* **When to use**
|
|
393
|
-
*
|
|
394
|
-
* Use when a CLI should ask interactively for a missing required flag or
|
|
395
|
-
* argument.
|
|
396
|
-
*
|
|
397
|
-
* **Details**
|
|
398
|
-
*
|
|
399
|
-
* `FallbackPrompt` accepts either a `Prompt` or an effect that builds one.
|
|
400
|
-
* Effectful prompt creation is lazy and runs only when the fallback is needed.
|
|
401
|
-
*
|
|
402
|
-
* **Gotchas**
|
|
403
|
-
*
|
|
404
|
-
* This only handles missing options and missing arguments. Invalid values do not
|
|
405
|
-
* prompt, and prompt cancellation re-fails with the original missing error.
|
|
406
|
-
*
|
|
407
|
-
* @see {@link FallbackPrompt} for accepted fallback prompt forms
|
|
408
|
-
* @see {@link withFallbackConfig} for loading a fallback from config
|
|
409
|
-
* @see {@link withDefault} for a pure default value
|
|
410
|
-
*
|
|
411
|
-
* @category combinators
|
|
412
|
-
* @since 4.0.0
|
|
413
|
-
*/
|
|
414
|
-
<B>(prompt: FallbackPrompt<B>): <Kind extends ParamKind, A>(self: Param<Kind, A>) => Param<Kind, A | B>;
|
|
415
|
-
/**
|
|
416
|
-
* Adds a fallback prompt that is shown when a required parameter is missing.
|
|
417
|
-
*
|
|
418
|
-
* **When to use**
|
|
419
|
-
*
|
|
420
|
-
* Use when a CLI should ask interactively for a missing required flag or
|
|
421
|
-
* argument.
|
|
422
|
-
*
|
|
423
|
-
* **Details**
|
|
424
|
-
*
|
|
425
|
-
* `FallbackPrompt` accepts either a `Prompt` or an effect that builds one.
|
|
426
|
-
* Effectful prompt creation is lazy and runs only when the fallback is needed.
|
|
427
|
-
*
|
|
428
|
-
* **Gotchas**
|
|
429
|
-
*
|
|
430
|
-
* This only handles missing options and missing arguments. Invalid values do not
|
|
431
|
-
* prompt, and prompt cancellation re-fails with the original missing error.
|
|
432
|
-
*
|
|
433
|
-
* @see {@link FallbackPrompt} for accepted fallback prompt forms
|
|
434
|
-
* @see {@link withFallbackConfig} for loading a fallback from config
|
|
435
|
-
* @see {@link withDefault} for a pure default value
|
|
436
|
-
*
|
|
437
|
-
* @category combinators
|
|
438
|
-
* @since 4.0.0
|
|
439
|
-
*/
|
|
440
|
-
<Kind extends ParamKind, A, B>(self: Param<Kind, A>, prompt: FallbackPrompt<B>): Param<Kind, A | B>;
|
|
441
|
-
};
|
|
429
|
+
export declare const choiceWithValue: <const Kind extends ParamKind, const Choices extends ReadonlyArray<readonly [string, any]>>(kind: Kind, name: string, choices: Choices) => Param<Kind, Choices[number][1]>;
|
|
442
430
|
/**
|
|
443
|
-
*
|
|
431
|
+
* Constructs command-line params that represent a choice between several
|
|
432
|
+
* string inputs.
|
|
444
433
|
*
|
|
445
|
-
*
|
|
434
|
+
* **Example** (Creating string choices)
|
|
435
|
+
*
|
|
436
|
+
* ```ts
|
|
437
|
+
* import { Param } from "effect/unstable/cli"
|
|
438
|
+
*
|
|
439
|
+
* const logLevel = Param.choice(Param.flagKind, "log-level", [
|
|
440
|
+
* "debug",
|
|
441
|
+
* "info",
|
|
442
|
+
* "warn",
|
|
443
|
+
* "error"
|
|
444
|
+
* ])
|
|
445
|
+
* ```
|
|
446
|
+
*
|
|
447
|
+
* @category constructors
|
|
446
448
|
* @since 4.0.0
|
|
447
449
|
*/
|
|
448
|
-
export
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
450
|
+
export declare const choice: <const Kind extends ParamKind, const Choices extends ReadonlyArray<string>>(kind: Kind, name: string, choices: Choices) => Param<Kind, Choices[number]>;
|
|
451
|
+
/**
|
|
452
|
+
* Creates a path parameter that accepts file or directory paths.
|
|
453
|
+
*
|
|
454
|
+
* **Example** (Creating path parameters)
|
|
455
|
+
*
|
|
456
|
+
* ```ts
|
|
457
|
+
* import { Param } from "effect/unstable/cli"
|
|
458
|
+
*
|
|
459
|
+
* // Basic path parameter
|
|
460
|
+
* const outputPath = Param.path(Param.flagKind, "output")
|
|
461
|
+
*
|
|
462
|
+
* // Path that must exist
|
|
463
|
+
* const inputPath = Param.path(Param.flagKind, "input", { mustExist: true })
|
|
464
|
+
*
|
|
465
|
+
* // File-only path
|
|
466
|
+
* const configFile = Param.path(Param.flagKind, "config", {
|
|
467
|
+
* pathType: "file",
|
|
468
|
+
* mustExist: true,
|
|
469
|
+
* typeName: "config-file"
|
|
470
|
+
* })
|
|
471
|
+
* ```
|
|
472
|
+
*
|
|
473
|
+
* @category constructors
|
|
474
|
+
* @since 4.0.0
|
|
475
|
+
*/
|
|
476
|
+
export declare const path: <Kind extends ParamKind>(kind: Kind, name: string, options?: {
|
|
477
|
+
readonly pathType?: Primitive.PathType | undefined;
|
|
478
|
+
readonly mustExist?: boolean | undefined;
|
|
479
|
+
readonly typeName?: string | undefined;
|
|
480
|
+
}) => Param<Kind, string>;
|
|
481
|
+
/**
|
|
482
|
+
* Creates a directory path parameter.
|
|
483
|
+
*
|
|
484
|
+
* **Details**
|
|
485
|
+
*
|
|
486
|
+
* This is a convenience function that creates a path parameter with the
|
|
487
|
+
* `pathType` set to `"directory"` and a default type name of `"directory"`.
|
|
488
|
+
*
|
|
489
|
+
* **Example** (Creating directory parameters)
|
|
490
|
+
*
|
|
491
|
+
* ```ts
|
|
492
|
+
* import { Param } from "effect/unstable/cli"
|
|
493
|
+
*
|
|
494
|
+
* // Basic directory parameter
|
|
495
|
+
* const outputDir = Param.directory(Param.flagKind, "output-dir")
|
|
496
|
+
*
|
|
497
|
+
* // Directory that must exist
|
|
498
|
+
* const sourceDir = Param.directory(Param.flagKind, "source", { mustExist: true })
|
|
499
|
+
*
|
|
500
|
+
* // Usage: --output-dir /path/to/dir --source /existing/dir
|
|
501
|
+
* ```
|
|
502
|
+
*
|
|
503
|
+
* @category constructors
|
|
504
|
+
* @since 4.0.0
|
|
505
|
+
*/
|
|
506
|
+
export declare const directory: <Kind extends ParamKind>(kind: Kind, name: string, options?: {
|
|
507
|
+
readonly mustExist?: boolean | undefined;
|
|
508
|
+
}) => Param<Kind, string>;
|
|
509
|
+
/**
|
|
510
|
+
* Creates a file path parameter.
|
|
511
|
+
*
|
|
512
|
+
* **Details**
|
|
513
|
+
*
|
|
514
|
+
* This is a convenience function that creates a path parameter with a
|
|
515
|
+
* `pathType` set to `"file"` and a default type name of `"file"`.
|
|
516
|
+
*
|
|
517
|
+
* **Example** (Creating file parameters)
|
|
518
|
+
*
|
|
519
|
+
* ```ts
|
|
520
|
+
* import { Param } from "effect/unstable/cli"
|
|
521
|
+
*
|
|
522
|
+
* // Basic file parameter
|
|
523
|
+
* const outputFile = Param.file(Param.flagKind, "output")
|
|
524
|
+
*
|
|
525
|
+
* // File that must exist
|
|
526
|
+
* const inputFile = Param.file(Param.flagKind, "input", { mustExist: true })
|
|
527
|
+
*
|
|
528
|
+
* // Usage: --output result.txt --input existing-file.txt
|
|
529
|
+
* ```
|
|
530
|
+
*
|
|
531
|
+
* @category constructors
|
|
532
|
+
* @since 4.0.0
|
|
533
|
+
*/
|
|
534
|
+
export declare const file: <Kind extends ParamKind>(kind: Kind, name: string, options?: {
|
|
535
|
+
readonly mustExist?: boolean | undefined;
|
|
536
|
+
}) => Param<Kind, string>;
|
|
537
|
+
/**
|
|
538
|
+
* Creates a redacted parameter for sensitive data like passwords.
|
|
539
|
+
* The value is masked in help output and logging.
|
|
540
|
+
*
|
|
541
|
+
* **Example** (Creating redacted parameters)
|
|
542
|
+
*
|
|
543
|
+
* ```ts
|
|
544
|
+
* import { Param } from "effect/unstable/cli"
|
|
545
|
+
*
|
|
546
|
+
* // Create a password parameter
|
|
547
|
+
* const password = Param.redacted(Param.flagKind, "password")
|
|
548
|
+
*
|
|
549
|
+
* // Create an API key argument
|
|
550
|
+
* const apiKey = Param.redacted(Param.argumentKind, "api-key")
|
|
551
|
+
*
|
|
552
|
+
* // Usage: --password (value will be hidden in help/logs)
|
|
553
|
+
* ```
|
|
554
|
+
*
|
|
555
|
+
* @category constructors
|
|
556
|
+
* @since 4.0.0
|
|
557
|
+
*/
|
|
558
|
+
export declare const redacted: <Kind extends ParamKind>(kind: Kind, name: string) => Param<Kind, Redacted.Redacted<string>>;
|
|
559
|
+
/**
|
|
560
|
+
* Creates a parameter that reads and returns file content as a string.
|
|
561
|
+
*
|
|
562
|
+
* **Example** (Reading file text)
|
|
563
|
+
*
|
|
564
|
+
* ```ts
|
|
565
|
+
* import { Param } from "effect/unstable/cli"
|
|
566
|
+
*
|
|
567
|
+
* // Read a config file as string
|
|
568
|
+
* const configContent = Param.fileText(Param.flagKind, "config")
|
|
569
|
+
*
|
|
570
|
+
* // Read a template file as argument
|
|
571
|
+
* const templateContent = Param.fileText(Param.argumentKind, "template")
|
|
572
|
+
*
|
|
573
|
+
* // Usage: --config config.txt (reads file content into string)
|
|
574
|
+
* ```
|
|
575
|
+
*
|
|
576
|
+
* @category constructors
|
|
577
|
+
* @since 4.0.0
|
|
578
|
+
*/
|
|
579
|
+
export declare const fileText: <Kind extends ParamKind>(kind: Kind, name: string) => Param<Kind, string>;
|
|
580
|
+
/**
|
|
581
|
+
* Creates a param that reads and parses the content of the specified file.
|
|
582
|
+
*
|
|
583
|
+
* **Details**
|
|
584
|
+
*
|
|
585
|
+
* The parser that is utilized will depend on the specified `format`, or the
|
|
586
|
+
* extension of the file passed on the command-line if no `format` is specified.
|
|
587
|
+
*
|
|
588
|
+
* **Example** (Parsing file contents)
|
|
589
|
+
*
|
|
590
|
+
* ```ts
|
|
591
|
+
* import { Param } from "effect/unstable/cli"
|
|
592
|
+
*
|
|
593
|
+
* // Will use the extension of the file passed on the command line to determine
|
|
594
|
+
* // the parser to use
|
|
595
|
+
* const config = Param.fileParse(Param.flagKind, "config")
|
|
596
|
+
*
|
|
597
|
+
* // Will use the JSON parser
|
|
598
|
+
* const jsonConfig = Param.fileParse(Param.flagKind, "json-config", {
|
|
599
|
+
* format: "json"
|
|
600
|
+
* })
|
|
601
|
+
* ```
|
|
602
|
+
*
|
|
603
|
+
* @category constructors
|
|
604
|
+
* @since 4.0.0
|
|
605
|
+
*/
|
|
606
|
+
export declare const fileParse: <Kind extends ParamKind>(kind: Kind, name: string, options?: Primitive.FileParseOptions | undefined) => Param<Kind, unknown>;
|
|
607
|
+
/**
|
|
608
|
+
* Creates a parameter that reads and validates file content using a schema.
|
|
609
|
+
*
|
|
610
|
+
* **Example** (Validating file contents)
|
|
611
|
+
*
|
|
612
|
+
* ```ts
|
|
613
|
+
* import { Schema } from "effect"
|
|
614
|
+
* import { Param } from "effect/unstable/cli"
|
|
615
|
+
* // Parse JSON config file
|
|
616
|
+
* const configSchema = Schema.Struct({
|
|
617
|
+
* port: Schema.Number,
|
|
618
|
+
* host: Schema.String
|
|
619
|
+
* })
|
|
620
|
+
*
|
|
621
|
+
* const config = Param.fileSchema(Param.flagKind, "config", configSchema, {
|
|
622
|
+
* format: "json"
|
|
623
|
+
* })
|
|
624
|
+
*
|
|
625
|
+
* // Parse YAML file
|
|
626
|
+
* const yamlConfig = Param.fileSchema(Param.flagKind, "config", configSchema, {
|
|
627
|
+
* format: "yaml"
|
|
628
|
+
* })
|
|
629
|
+
*
|
|
630
|
+
* // Usage: --config config.json (reads and validates file content)
|
|
631
|
+
* ```
|
|
632
|
+
*
|
|
633
|
+
* @category constructors
|
|
634
|
+
* @since 4.0.0
|
|
635
|
+
*/
|
|
636
|
+
export declare const fileSchema: <Kind extends ParamKind, A>(kind: Kind, name: string, schema: Schema.ConstraintDecoder<A, Environment>, options?: Primitive.FileSchemaOptions | undefined) => Param<Kind, A>;
|
|
637
|
+
/**
|
|
638
|
+
* Creates a param that parses key=value pairs.
|
|
639
|
+
*
|
|
640
|
+
* **When to use**
|
|
641
|
+
*
|
|
642
|
+
* Use when you need command-line options or arguments that collect `key=value`
|
|
643
|
+
* configuration entries.
|
|
644
|
+
*
|
|
645
|
+
* **Details**
|
|
646
|
+
*
|
|
647
|
+
* Requires at least one key=value pair. The parsed pairs are merged into a
|
|
648
|
+
* single record object.
|
|
649
|
+
*
|
|
650
|
+
* **Example** (Parsing key-value pairs)
|
|
651
|
+
*
|
|
652
|
+
* ```ts
|
|
653
|
+
* import { Param } from "effect/unstable/cli"
|
|
654
|
+
*
|
|
655
|
+
* const env = Param.keyValuePair(Param.flagKind, "env")
|
|
656
|
+
* // --env FOO=bar --env BAZ=qux will parse to { FOO: "bar", BAZ: "qux" }
|
|
657
|
+
*
|
|
658
|
+
* const props = Param.keyValuePair(Param.flagKind, "property")
|
|
659
|
+
* // --property name=value --property debug=true
|
|
660
|
+
* ```
|
|
661
|
+
*
|
|
662
|
+
* @category constructors
|
|
663
|
+
* @since 4.0.0
|
|
664
|
+
*/
|
|
665
|
+
export declare const keyValuePair: <Kind extends ParamKind>(kind: Kind, name: string) => Param<Kind, Record<string, string>>;
|
|
666
|
+
/**
|
|
667
|
+
* Creates an empty sentinel parameter that always fails to parse.
|
|
668
|
+
*
|
|
669
|
+
* **When to use**
|
|
670
|
+
*
|
|
671
|
+
* Use when you need an empty CLI parameter sentinel for optional parameter
|
|
672
|
+
* construction or internal combinators.
|
|
673
|
+
*
|
|
674
|
+
* **Example** (Creating sentinel parameters)
|
|
675
|
+
*
|
|
676
|
+
* ```ts
|
|
677
|
+
* import { Param } from "effect/unstable/cli"
|
|
678
|
+
*
|
|
679
|
+
* const disabledDebugParam = Param.none(Param.flagKind)
|
|
680
|
+
*
|
|
681
|
+
* const makeDebugParam = (enableDebug: boolean) =>
|
|
682
|
+
* enableDebug ? Param.string(Param.flagKind, "debug") : disabledDebugParam
|
|
683
|
+
*
|
|
684
|
+
* console.log(makeDebugParam(true) === disabledDebugParam) // false
|
|
685
|
+
* console.log(makeDebugParam(false) === disabledDebugParam) // true
|
|
686
|
+
* ```
|
|
687
|
+
*
|
|
688
|
+
* @category constructors
|
|
689
|
+
* @since 4.0.0
|
|
690
|
+
*/
|
|
691
|
+
export declare const none: <Kind extends ParamKind>(kind: Kind) => Param<Kind, never>;
|
|
692
|
+
/**
|
|
693
|
+
* Adds an alias to an option.
|
|
694
|
+
*
|
|
695
|
+
* **When to use**
|
|
696
|
+
*
|
|
697
|
+
* Use when you need a CLI parameter to accept an alternate name, such as "-f"
|
|
698
|
+
* for "--force".
|
|
699
|
+
*
|
|
700
|
+
* **Details**
|
|
701
|
+
*
|
|
702
|
+
* This works on any param structure by recursively finding the underlying
|
|
703
|
+
* `Single` node and applying the alias there.
|
|
704
|
+
*
|
|
705
|
+
* **Example** (Adding parameter aliases)
|
|
706
|
+
*
|
|
707
|
+
* ```ts
|
|
708
|
+
* import { Param } from "effect/unstable/cli"
|
|
709
|
+
*
|
|
710
|
+
* const force = Param.boolean(Param.flagKind, "force").pipe(
|
|
711
|
+
* Param.withAlias("-f"),
|
|
712
|
+
* Param.withAlias("-F")
|
|
713
|
+
* )
|
|
714
|
+
*
|
|
715
|
+
* // Also works on composed params:
|
|
716
|
+
* const count = Param.integer(Param.flagKind, "count").pipe(
|
|
717
|
+
* Param.optional,
|
|
718
|
+
* Param.withAlias("-c") // finds the underlying Single and adds alias
|
|
719
|
+
* )
|
|
720
|
+
* ```
|
|
721
|
+
*
|
|
722
|
+
* @category combinators
|
|
723
|
+
* @since 4.0.0
|
|
724
|
+
*/
|
|
725
|
+
export declare const withAlias: {
|
|
726
|
+
/**
|
|
727
|
+
* Adds an alias to an option.
|
|
728
|
+
*
|
|
729
|
+
* **When to use**
|
|
730
|
+
*
|
|
731
|
+
* Use when you need a CLI parameter to accept an alternate name, such as "-f"
|
|
732
|
+
* for "--force".
|
|
733
|
+
*
|
|
734
|
+
* **Details**
|
|
735
|
+
*
|
|
736
|
+
* This works on any param structure by recursively finding the underlying
|
|
737
|
+
* `Single` node and applying the alias there.
|
|
738
|
+
*
|
|
739
|
+
* **Example** (Adding parameter aliases)
|
|
740
|
+
*
|
|
741
|
+
* ```ts
|
|
742
|
+
* import { Param } from "effect/unstable/cli"
|
|
743
|
+
*
|
|
744
|
+
* const force = Param.boolean(Param.flagKind, "force").pipe(
|
|
745
|
+
* Param.withAlias("-f"),
|
|
746
|
+
* Param.withAlias("-F")
|
|
747
|
+
* )
|
|
748
|
+
*
|
|
749
|
+
* // Also works on composed params:
|
|
750
|
+
* const count = Param.integer(Param.flagKind, "count").pipe(
|
|
751
|
+
* Param.optional,
|
|
752
|
+
* Param.withAlias("-c") // finds the underlying Single and adds alias
|
|
753
|
+
* )
|
|
754
|
+
* ```
|
|
755
|
+
*
|
|
756
|
+
* @category combinators
|
|
757
|
+
* @since 4.0.0
|
|
758
|
+
*/
|
|
759
|
+
<Kind extends ParamKind, A>(alias: string): (self: Param<Kind, A>) => Param<Kind, A>;
|
|
760
|
+
/**
|
|
761
|
+
* Adds an alias to an option.
|
|
762
|
+
*
|
|
763
|
+
* **When to use**
|
|
764
|
+
*
|
|
765
|
+
* Use when you need a CLI parameter to accept an alternate name, such as "-f"
|
|
766
|
+
* for "--force".
|
|
767
|
+
*
|
|
768
|
+
* **Details**
|
|
769
|
+
*
|
|
770
|
+
* This works on any param structure by recursively finding the underlying
|
|
771
|
+
* `Single` node and applying the alias there.
|
|
772
|
+
*
|
|
773
|
+
* **Example** (Adding parameter aliases)
|
|
774
|
+
*
|
|
775
|
+
* ```ts
|
|
776
|
+
* import { Param } from "effect/unstable/cli"
|
|
777
|
+
*
|
|
778
|
+
* const force = Param.boolean(Param.flagKind, "force").pipe(
|
|
779
|
+
* Param.withAlias("-f"),
|
|
780
|
+
* Param.withAlias("-F")
|
|
781
|
+
* )
|
|
782
|
+
*
|
|
783
|
+
* // Also works on composed params:
|
|
784
|
+
* const count = Param.integer(Param.flagKind, "count").pipe(
|
|
785
|
+
* Param.optional,
|
|
786
|
+
* Param.withAlias("-c") // finds the underlying Single and adds alias
|
|
787
|
+
* )
|
|
788
|
+
* ```
|
|
789
|
+
*
|
|
790
|
+
* @category combinators
|
|
791
|
+
* @since 4.0.0
|
|
792
|
+
*/
|
|
793
|
+
<Kind extends ParamKind, A>(self: Param<Kind, A>, alias: string): Param<Kind, A>;
|
|
794
|
+
};
|
|
795
|
+
/**
|
|
796
|
+
* Adds a description to an option for help text.
|
|
797
|
+
*
|
|
798
|
+
* **Details**
|
|
799
|
+
*
|
|
800
|
+
* Descriptions provide users with information about what the option does
|
|
801
|
+
* when they view help documentation.
|
|
802
|
+
*
|
|
803
|
+
* **Example** (Adding help descriptions)
|
|
804
|
+
*
|
|
805
|
+
* ```ts
|
|
806
|
+
* import { Param } from "effect/unstable/cli"
|
|
807
|
+
*
|
|
808
|
+
* const verbose = Param.boolean(Param.flagKind, "verbose").pipe(
|
|
809
|
+
* Param.withAlias("-v"),
|
|
810
|
+
* Param.withDescription("Enable verbose output")
|
|
811
|
+
* )
|
|
812
|
+
* ```
|
|
813
|
+
*
|
|
814
|
+
* @category combinators
|
|
815
|
+
* @since 4.0.0
|
|
816
|
+
*/
|
|
817
|
+
export declare const withDescription: {
|
|
818
|
+
/**
|
|
819
|
+
* Adds a description to an option for help text.
|
|
820
|
+
*
|
|
821
|
+
* **Details**
|
|
822
|
+
*
|
|
823
|
+
* Descriptions provide users with information about what the option does
|
|
824
|
+
* when they view help documentation.
|
|
825
|
+
*
|
|
826
|
+
* **Example** (Adding help descriptions)
|
|
827
|
+
*
|
|
828
|
+
* ```ts
|
|
829
|
+
* import { Param } from "effect/unstable/cli"
|
|
830
|
+
*
|
|
831
|
+
* const verbose = Param.boolean(Param.flagKind, "verbose").pipe(
|
|
832
|
+
* Param.withAlias("-v"),
|
|
833
|
+
* Param.withDescription("Enable verbose output")
|
|
834
|
+
* )
|
|
835
|
+
* ```
|
|
836
|
+
*
|
|
837
|
+
* @category combinators
|
|
838
|
+
* @since 4.0.0
|
|
839
|
+
*/
|
|
840
|
+
<Kind extends ParamKind, A>(description: string): (self: Param<Kind, A>) => Param<Kind, A>;
|
|
841
|
+
/**
|
|
842
|
+
* Adds a description to an option for help text.
|
|
843
|
+
*
|
|
844
|
+
* **Details**
|
|
845
|
+
*
|
|
846
|
+
* Descriptions provide users with information about what the option does
|
|
847
|
+
* when they view help documentation.
|
|
848
|
+
*
|
|
849
|
+
* **Example** (Adding help descriptions)
|
|
850
|
+
*
|
|
851
|
+
* ```ts
|
|
852
|
+
* import { Param } from "effect/unstable/cli"
|
|
853
|
+
*
|
|
854
|
+
* const verbose = Param.boolean(Param.flagKind, "verbose").pipe(
|
|
855
|
+
* Param.withAlias("-v"),
|
|
856
|
+
* Param.withDescription("Enable verbose output")
|
|
857
|
+
* )
|
|
858
|
+
* ```
|
|
859
|
+
*
|
|
860
|
+
* @category combinators
|
|
861
|
+
* @since 4.0.0
|
|
862
|
+
*/
|
|
863
|
+
<Kind extends ParamKind, A>(self: Param<Kind, A>, description: string): Param<Kind, A>;
|
|
864
|
+
};
|
|
865
|
+
/**
|
|
866
|
+
* Hides a parameter from generated help output and completions while keeping
|
|
867
|
+
* it parseable on the command line.
|
|
868
|
+
*
|
|
869
|
+
* **When to use**
|
|
870
|
+
*
|
|
871
|
+
* Use when experimental, internal, or deprecated flags should be accepted but
|
|
872
|
+
* not advertised.
|
|
873
|
+
*
|
|
874
|
+
* **Example** (Hiding a flag from help)
|
|
875
|
+
*
|
|
876
|
+
* ```ts
|
|
877
|
+
* import { Param } from "effect/unstable/cli"
|
|
878
|
+
*
|
|
879
|
+
* const experimental = Param.boolean(Param.flagKind, "experimental-foo").pipe(
|
|
880
|
+
* Param.withHidden
|
|
881
|
+
* )
|
|
882
|
+
* ```
|
|
883
|
+
*
|
|
884
|
+
* @category metadata
|
|
885
|
+
* @since 4.0.0
|
|
886
|
+
*/
|
|
887
|
+
export declare const withHidden: <Kind extends ParamKind, A>(self: Param<Kind, A>) => Param<Kind, A>;
|
|
888
|
+
/**
|
|
889
|
+
* Transforms the parsed value of an option using a mapping function.
|
|
890
|
+
*
|
|
891
|
+
* **Example** (Mapping parsed values)
|
|
892
|
+
*
|
|
893
|
+
* ```ts
|
|
894
|
+
* import { Param } from "effect/unstable/cli"
|
|
895
|
+
*
|
|
896
|
+
* const port = Param.integer(Param.flagKind, "port").pipe(
|
|
897
|
+
* Param.map((n) => ({ port: n, url: `http://localhost:${n}` }))
|
|
898
|
+
* )
|
|
899
|
+
* ```
|
|
900
|
+
*
|
|
901
|
+
* @category combinators
|
|
902
|
+
* @since 4.0.0
|
|
903
|
+
*/
|
|
904
|
+
export declare const map: {
|
|
905
|
+
/**
|
|
906
|
+
* Transforms the parsed value of an option using a mapping function.
|
|
907
|
+
*
|
|
908
|
+
* **Example** (Mapping parsed values)
|
|
909
|
+
*
|
|
910
|
+
* ```ts
|
|
911
|
+
* import { Param } from "effect/unstable/cli"
|
|
912
|
+
*
|
|
913
|
+
* const port = Param.integer(Param.flagKind, "port").pipe(
|
|
914
|
+
* Param.map((n) => ({ port: n, url: `http://localhost:${n}` }))
|
|
915
|
+
* )
|
|
916
|
+
* ```
|
|
917
|
+
*
|
|
918
|
+
* @category combinators
|
|
919
|
+
* @since 4.0.0
|
|
920
|
+
*/
|
|
921
|
+
<A, B>(f: (a: A) => B): <Kind extends ParamKind>(self: Param<Kind, A>) => Param<Kind, B>;
|
|
922
|
+
/**
|
|
923
|
+
* Transforms the parsed value of an option using a mapping function.
|
|
924
|
+
*
|
|
925
|
+
* **Example** (Mapping parsed values)
|
|
926
|
+
*
|
|
927
|
+
* ```ts
|
|
928
|
+
* import { Param } from "effect/unstable/cli"
|
|
929
|
+
*
|
|
930
|
+
* const port = Param.integer(Param.flagKind, "port").pipe(
|
|
931
|
+
* Param.map((n) => ({ port: n, url: `http://localhost:${n}` }))
|
|
932
|
+
* )
|
|
933
|
+
* ```
|
|
934
|
+
*
|
|
935
|
+
* @category combinators
|
|
936
|
+
* @since 4.0.0
|
|
937
|
+
*/
|
|
938
|
+
<Kind extends ParamKind, A, B>(self: Param<Kind, A>, f: (a: A) => B): Param<Kind, B>;
|
|
939
|
+
};
|
|
940
|
+
/**
|
|
941
|
+
* Transforms the parsed value of an option using an effectful mapping function.
|
|
942
|
+
*
|
|
943
|
+
* **Example** (Mapping parsed values effectfully)
|
|
944
|
+
*
|
|
945
|
+
* ```ts
|
|
946
|
+
* import { Effect } from "effect"
|
|
947
|
+
* import { CliError, Param } from "effect/unstable/cli"
|
|
948
|
+
*
|
|
949
|
+
* const validatedEmail = Param.string(Param.flagKind, "email").pipe(
|
|
950
|
+
* Param.mapEffect((email) =>
|
|
951
|
+
* email.includes("@")
|
|
952
|
+
* ? Effect.succeed(email)
|
|
953
|
+
* : Effect.fail(
|
|
954
|
+
* new CliError.InvalidValue({
|
|
955
|
+
* option: "email",
|
|
956
|
+
* value: email,
|
|
957
|
+
* expected: "valid email format",
|
|
958
|
+
* kind: "flag"
|
|
959
|
+
* })
|
|
960
|
+
* )
|
|
961
|
+
* )
|
|
962
|
+
* )
|
|
963
|
+
* ```
|
|
964
|
+
*
|
|
965
|
+
* @category combinators
|
|
966
|
+
* @since 4.0.0
|
|
967
|
+
*/
|
|
968
|
+
export declare const mapEffect: {
|
|
969
|
+
/**
|
|
970
|
+
* Transforms the parsed value of an option using an effectful mapping function.
|
|
971
|
+
*
|
|
972
|
+
* **Example** (Mapping parsed values effectfully)
|
|
973
|
+
*
|
|
974
|
+
* ```ts
|
|
975
|
+
* import { Effect } from "effect"
|
|
976
|
+
* import { CliError, Param } from "effect/unstable/cli"
|
|
977
|
+
*
|
|
978
|
+
* const validatedEmail = Param.string(Param.flagKind, "email").pipe(
|
|
979
|
+
* Param.mapEffect((email) =>
|
|
980
|
+
* email.includes("@")
|
|
981
|
+
* ? Effect.succeed(email)
|
|
982
|
+
* : Effect.fail(
|
|
983
|
+
* new CliError.InvalidValue({
|
|
984
|
+
* option: "email",
|
|
985
|
+
* value: email,
|
|
986
|
+
* expected: "valid email format",
|
|
987
|
+
* kind: "flag"
|
|
988
|
+
* })
|
|
989
|
+
* )
|
|
990
|
+
* )
|
|
991
|
+
* )
|
|
992
|
+
* ```
|
|
993
|
+
*
|
|
994
|
+
* @category combinators
|
|
995
|
+
* @since 4.0.0
|
|
996
|
+
*/
|
|
997
|
+
<A, B>(f: (a: A) => Effect.Effect<B, CliError.CliError, Environment>): <Kind extends ParamKind>(self: Param<Kind, A>) => Param<Kind, B>;
|
|
998
|
+
/**
|
|
999
|
+
* Transforms the parsed value of an option using an effectful mapping function.
|
|
1000
|
+
*
|
|
1001
|
+
* **Example** (Mapping parsed values effectfully)
|
|
1002
|
+
*
|
|
1003
|
+
* ```ts
|
|
1004
|
+
* import { Effect } from "effect"
|
|
1005
|
+
* import { CliError, Param } from "effect/unstable/cli"
|
|
1006
|
+
*
|
|
1007
|
+
* const validatedEmail = Param.string(Param.flagKind, "email").pipe(
|
|
1008
|
+
* Param.mapEffect((email) =>
|
|
1009
|
+
* email.includes("@")
|
|
1010
|
+
* ? Effect.succeed(email)
|
|
1011
|
+
* : Effect.fail(
|
|
1012
|
+
* new CliError.InvalidValue({
|
|
1013
|
+
* option: "email",
|
|
1014
|
+
* value: email,
|
|
1015
|
+
* expected: "valid email format",
|
|
1016
|
+
* kind: "flag"
|
|
1017
|
+
* })
|
|
1018
|
+
* )
|
|
1019
|
+
* )
|
|
1020
|
+
* )
|
|
1021
|
+
* ```
|
|
1022
|
+
*
|
|
1023
|
+
* @category combinators
|
|
1024
|
+
* @since 4.0.0
|
|
1025
|
+
*/
|
|
1026
|
+
<Kind extends ParamKind, A, B>(self: Param<Kind, A>, f: (a: A) => Effect.Effect<B, CliError.CliError, Environment>): Param<Kind, B>;
|
|
1027
|
+
};
|
|
1028
|
+
/**
|
|
1029
|
+
* Transforms the parsed value of an option using a function that may throw,
|
|
1030
|
+
* converting any thrown errors into failure messages.
|
|
1031
|
+
*
|
|
1032
|
+
* **Example** (Mapping thrown errors)
|
|
1033
|
+
*
|
|
1034
|
+
* ```ts
|
|
1035
|
+
* import { Param } from "effect/unstable/cli"
|
|
1036
|
+
*
|
|
1037
|
+
* const parsedJson = Param.string(Param.flagKind, "config").pipe(
|
|
1038
|
+
* Param.mapTryCatch(
|
|
1039
|
+
* (str) => JSON.parse(str),
|
|
1040
|
+
* (error) =>
|
|
1041
|
+
* `Invalid JSON: ${error instanceof Error ? error.message : String(error)}`
|
|
1042
|
+
* )
|
|
1043
|
+
* )
|
|
1044
|
+
* ```
|
|
1045
|
+
*
|
|
1046
|
+
* @category combinators
|
|
1047
|
+
* @since 4.0.0
|
|
1048
|
+
*/
|
|
1049
|
+
export declare const mapTryCatch: {
|
|
1050
|
+
/**
|
|
1051
|
+
* Transforms the parsed value of an option using a function that may throw,
|
|
1052
|
+
* converting any thrown errors into failure messages.
|
|
1053
|
+
*
|
|
1054
|
+
* **Example** (Mapping thrown errors)
|
|
1055
|
+
*
|
|
1056
|
+
* ```ts
|
|
1057
|
+
* import { Param } from "effect/unstable/cli"
|
|
1058
|
+
*
|
|
1059
|
+
* const parsedJson = Param.string(Param.flagKind, "config").pipe(
|
|
1060
|
+
* Param.mapTryCatch(
|
|
1061
|
+
* (str) => JSON.parse(str),
|
|
1062
|
+
* (error) =>
|
|
1063
|
+
* `Invalid JSON: ${error instanceof Error ? error.message : String(error)}`
|
|
1064
|
+
* )
|
|
1065
|
+
* )
|
|
1066
|
+
* ```
|
|
1067
|
+
*
|
|
1068
|
+
* @category combinators
|
|
1069
|
+
* @since 4.0.0
|
|
1070
|
+
*/
|
|
1071
|
+
<A, B>(f: (a: A) => B, onError: (error: unknown) => string): <Kind extends ParamKind>(self: Param<Kind, A>) => Param<Kind, B>;
|
|
1072
|
+
/**
|
|
1073
|
+
* Transforms the parsed value of an option using a function that may throw,
|
|
1074
|
+
* converting any thrown errors into failure messages.
|
|
1075
|
+
*
|
|
1076
|
+
* **Example** (Mapping thrown errors)
|
|
1077
|
+
*
|
|
1078
|
+
* ```ts
|
|
1079
|
+
* import { Param } from "effect/unstable/cli"
|
|
1080
|
+
*
|
|
1081
|
+
* const parsedJson = Param.string(Param.flagKind, "config").pipe(
|
|
1082
|
+
* Param.mapTryCatch(
|
|
1083
|
+
* (str) => JSON.parse(str),
|
|
1084
|
+
* (error) =>
|
|
1085
|
+
* `Invalid JSON: ${error instanceof Error ? error.message : String(error)}`
|
|
1086
|
+
* )
|
|
1087
|
+
* )
|
|
1088
|
+
* ```
|
|
1089
|
+
*
|
|
1090
|
+
* @category combinators
|
|
1091
|
+
* @since 4.0.0
|
|
1092
|
+
*/
|
|
1093
|
+
<Kind extends ParamKind, A, B>(self: Param<Kind, A>, f: (a: A) => B, onError: (error: unknown) => string): Param<Kind, B>;
|
|
1094
|
+
};
|
|
1095
|
+
/**
|
|
1096
|
+
* Makes a flag or positional argument optional.
|
|
1097
|
+
*
|
|
1098
|
+
* **Details**
|
|
1099
|
+
*
|
|
1100
|
+
* When the parameter is absent, parsing succeeds with `Option.none()` instead
|
|
1101
|
+
* of failing with a missing option or missing argument error. When present, the
|
|
1102
|
+
* parsed value is wrapped in `Option.some()`.
|
|
1103
|
+
*
|
|
1104
|
+
* **Example** (Making parameters optional)
|
|
1105
|
+
*
|
|
1106
|
+
* ```ts
|
|
1107
|
+
* import { Param } from "effect/unstable/cli"
|
|
1108
|
+
*
|
|
1109
|
+
* // Create an optional port option
|
|
1110
|
+
* // - When not provided: returns Option.none()
|
|
1111
|
+
* // - When provided: returns Option.some(parsedValue)
|
|
1112
|
+
* const port = Param.optional(Param.integer(Param.flagKind, "port"))
|
|
1113
|
+
* ```
|
|
1114
|
+
*
|
|
1115
|
+
* @category combinators
|
|
1116
|
+
* @since 4.0.0
|
|
1117
|
+
*/
|
|
1118
|
+
export declare const optional: <Kind extends ParamKind, A>(param: Param<Kind, A>) => Param<Kind, Option.Option<A>>;
|
|
1119
|
+
/**
|
|
1120
|
+
* Makes a flag or positional argument optional by supplying a fallback value.
|
|
1121
|
+
*
|
|
1122
|
+
* **Details**
|
|
1123
|
+
*
|
|
1124
|
+
* The fallback may be a pure value or an effect. It is used only when the
|
|
1125
|
+
* parameter is absent; provided values are parsed normally.
|
|
1126
|
+
*
|
|
1127
|
+
* **Example** (Providing default values)
|
|
1128
|
+
*
|
|
1129
|
+
* ```ts
|
|
1130
|
+
* import { Param } from "effect/unstable/cli"
|
|
1131
|
+
*
|
|
1132
|
+
* // Using the pipe operator to make an option optional
|
|
1133
|
+
* const port = Param.integer(Param.flagKind, "port").pipe(
|
|
1134
|
+
* Param.withDefault(8080)
|
|
1135
|
+
* )
|
|
1136
|
+
*
|
|
1137
|
+
* // Can also be used with other combinators
|
|
1138
|
+
* const verbose = Param.boolean(Param.flagKind, "verbose").pipe(
|
|
1139
|
+
* Param.withAlias("-v"),
|
|
1140
|
+
* Param.withDescription("Enable verbose output"),
|
|
1141
|
+
* Param.withDefault(false)
|
|
1142
|
+
* )
|
|
1143
|
+
* ```
|
|
1144
|
+
*
|
|
1145
|
+
* @category combinators
|
|
1146
|
+
* @since 4.0.0
|
|
1147
|
+
*/
|
|
1148
|
+
export declare const withDefault: {
|
|
1149
|
+
/**
|
|
1150
|
+
* Makes a flag or positional argument optional by supplying a fallback value.
|
|
1151
|
+
*
|
|
1152
|
+
* **Details**
|
|
1153
|
+
*
|
|
1154
|
+
* The fallback may be a pure value or an effect. It is used only when the
|
|
1155
|
+
* parameter is absent; provided values are parsed normally.
|
|
1156
|
+
*
|
|
1157
|
+
* **Example** (Providing default values)
|
|
1158
|
+
*
|
|
1159
|
+
* ```ts
|
|
1160
|
+
* import { Param } from "effect/unstable/cli"
|
|
1161
|
+
*
|
|
1162
|
+
* // Using the pipe operator to make an option optional
|
|
1163
|
+
* const port = Param.integer(Param.flagKind, "port").pipe(
|
|
1164
|
+
* Param.withDefault(8080)
|
|
1165
|
+
* )
|
|
1166
|
+
*
|
|
1167
|
+
* // Can also be used with other combinators
|
|
1168
|
+
* const verbose = Param.boolean(Param.flagKind, "verbose").pipe(
|
|
1169
|
+
* Param.withAlias("-v"),
|
|
1170
|
+
* Param.withDescription("Enable verbose output"),
|
|
1171
|
+
* Param.withDefault(false)
|
|
1172
|
+
* )
|
|
1173
|
+
* ```
|
|
1174
|
+
*
|
|
1175
|
+
* @category combinators
|
|
1176
|
+
* @since 4.0.0
|
|
1177
|
+
*/
|
|
1178
|
+
<const B>(defaultValue: B | Effect.Effect<B, CliError.CliError, Environment>): <Kind extends ParamKind, A>(self: Param<Kind, A>) => Param<Kind, A | B>;
|
|
1179
|
+
/**
|
|
1180
|
+
* Makes a flag or positional argument optional by supplying a fallback value.
|
|
1181
|
+
*
|
|
1182
|
+
* **Details**
|
|
1183
|
+
*
|
|
1184
|
+
* The fallback may be a pure value or an effect. It is used only when the
|
|
1185
|
+
* parameter is absent; provided values are parsed normally.
|
|
1186
|
+
*
|
|
1187
|
+
* **Example** (Providing default values)
|
|
1188
|
+
*
|
|
1189
|
+
* ```ts
|
|
1190
|
+
* import { Param } from "effect/unstable/cli"
|
|
1191
|
+
*
|
|
1192
|
+
* // Using the pipe operator to make an option optional
|
|
1193
|
+
* const port = Param.integer(Param.flagKind, "port").pipe(
|
|
1194
|
+
* Param.withDefault(8080)
|
|
1195
|
+
* )
|
|
1196
|
+
*
|
|
1197
|
+
* // Can also be used with other combinators
|
|
1198
|
+
* const verbose = Param.boolean(Param.flagKind, "verbose").pipe(
|
|
1199
|
+
* Param.withAlias("-v"),
|
|
1200
|
+
* Param.withDescription("Enable verbose output"),
|
|
1201
|
+
* Param.withDefault(false)
|
|
1202
|
+
* )
|
|
1203
|
+
* ```
|
|
1204
|
+
*
|
|
1205
|
+
* @category combinators
|
|
1206
|
+
* @since 4.0.0
|
|
1207
|
+
*/
|
|
1208
|
+
<Kind extends ParamKind, A, const B>(self: Param<Kind, A>, defaultValue: B | Effect.Effect<B, CliError.CliError, Environment>): Param<Kind, A | B>;
|
|
1209
|
+
};
|
|
1210
|
+
/**
|
|
1211
|
+
* Adds a fallback config that is loaded when a required parameter is missing.
|
|
1212
|
+
*
|
|
1213
|
+
* **When to use**
|
|
1214
|
+
*
|
|
1215
|
+
* Use when you need config to provide a fallback source for required flags or
|
|
1216
|
+
* arguments that are absent from CLI input.
|
|
1217
|
+
*
|
|
1218
|
+
* **Details**
|
|
1219
|
+
*
|
|
1220
|
+
* Provided CLI values win. Config is loaded only after a missing option or
|
|
1221
|
+
* missing argument error.
|
|
1222
|
+
*
|
|
1223
|
+
* **Gotchas**
|
|
1224
|
+
*
|
|
1225
|
+
* Missing config preserves the original missing-parameter error. Config parse
|
|
1226
|
+
* failure becomes `CliError.InvalidValue`.
|
|
1227
|
+
*
|
|
1228
|
+
* @see {@link withDefault} for a pure default value
|
|
1229
|
+
* @see {@link withFallbackPrompt} for prompting interactively when input is missing
|
|
1230
|
+
*
|
|
1231
|
+
* @category combinators
|
|
1232
|
+
* @since 4.0.0
|
|
1233
|
+
*/
|
|
1234
|
+
export declare const withFallbackConfig: {
|
|
1235
|
+
/**
|
|
1236
|
+
* Adds a fallback config that is loaded when a required parameter is missing.
|
|
1237
|
+
*
|
|
1238
|
+
* **When to use**
|
|
1239
|
+
*
|
|
1240
|
+
* Use when you need config to provide a fallback source for required flags or
|
|
1241
|
+
* arguments that are absent from CLI input.
|
|
1242
|
+
*
|
|
1243
|
+
* **Details**
|
|
1244
|
+
*
|
|
1245
|
+
* Provided CLI values win. Config is loaded only after a missing option or
|
|
1246
|
+
* missing argument error.
|
|
1247
|
+
*
|
|
1248
|
+
* **Gotchas**
|
|
1249
|
+
*
|
|
1250
|
+
* Missing config preserves the original missing-parameter error. Config parse
|
|
1251
|
+
* failure becomes `CliError.InvalidValue`.
|
|
1252
|
+
*
|
|
1253
|
+
* @see {@link withDefault} for a pure default value
|
|
1254
|
+
* @see {@link withFallbackPrompt} for prompting interactively when input is missing
|
|
1255
|
+
*
|
|
1256
|
+
* @category combinators
|
|
1257
|
+
* @since 4.0.0
|
|
1258
|
+
*/
|
|
1259
|
+
<B>(config: Config.Config<B>): <Kind extends ParamKind, A>(self: Param<Kind, A>) => Param<Kind, A | B>;
|
|
1260
|
+
/**
|
|
1261
|
+
* Adds a fallback config that is loaded when a required parameter is missing.
|
|
1262
|
+
*
|
|
1263
|
+
* **When to use**
|
|
1264
|
+
*
|
|
1265
|
+
* Use when you need config to provide a fallback source for required flags or
|
|
1266
|
+
* arguments that are absent from CLI input.
|
|
1267
|
+
*
|
|
1268
|
+
* **Details**
|
|
1269
|
+
*
|
|
1270
|
+
* Provided CLI values win. Config is loaded only after a missing option or
|
|
1271
|
+
* missing argument error.
|
|
1272
|
+
*
|
|
1273
|
+
* **Gotchas**
|
|
1274
|
+
*
|
|
1275
|
+
* Missing config preserves the original missing-parameter error. Config parse
|
|
1276
|
+
* failure becomes `CliError.InvalidValue`.
|
|
1277
|
+
*
|
|
1278
|
+
* @see {@link withDefault} for a pure default value
|
|
1279
|
+
* @see {@link withFallbackPrompt} for prompting interactively when input is missing
|
|
1280
|
+
*
|
|
1281
|
+
* @category combinators
|
|
1282
|
+
* @since 4.0.0
|
|
1283
|
+
*/
|
|
1284
|
+
<Kind extends ParamKind, A, B>(self: Param<Kind, A>, config: Config.Config<B>): Param<Kind, A | B>;
|
|
1285
|
+
};
|
|
1286
|
+
/**
|
|
1287
|
+
* Adds a fallback prompt that is shown when a required parameter is missing.
|
|
1288
|
+
*
|
|
1289
|
+
* **When to use**
|
|
1290
|
+
*
|
|
1291
|
+
* Use when a CLI should ask interactively for a missing required flag or
|
|
1292
|
+
* argument.
|
|
1293
|
+
*
|
|
1294
|
+
* **Details**
|
|
1295
|
+
*
|
|
1296
|
+
* `FallbackPrompt` accepts either a `Prompt` or an effect that builds one.
|
|
1297
|
+
* Effectful prompt creation is lazy and runs only when the fallback is needed.
|
|
1298
|
+
*
|
|
1299
|
+
* **Gotchas**
|
|
1300
|
+
*
|
|
1301
|
+
* This only handles missing options and missing arguments. Invalid values do not
|
|
1302
|
+
* prompt, and prompt cancellation re-fails with the original missing error.
|
|
1303
|
+
*
|
|
1304
|
+
* @see {@link FallbackPrompt} for accepted fallback prompt forms
|
|
1305
|
+
* @see {@link withFallbackConfig} for loading a fallback from config
|
|
1306
|
+
* @see {@link withDefault} for a pure default value
|
|
1307
|
+
*
|
|
1308
|
+
* @category combinators
|
|
1309
|
+
* @since 4.0.0
|
|
1310
|
+
*/
|
|
1311
|
+
export declare const withFallbackPrompt: {
|
|
1312
|
+
/**
|
|
1313
|
+
* Adds a fallback prompt that is shown when a required parameter is missing.
|
|
1314
|
+
*
|
|
1315
|
+
* **When to use**
|
|
1316
|
+
*
|
|
1317
|
+
* Use when a CLI should ask interactively for a missing required flag or
|
|
1318
|
+
* argument.
|
|
1319
|
+
*
|
|
1320
|
+
* **Details**
|
|
1321
|
+
*
|
|
1322
|
+
* `FallbackPrompt` accepts either a `Prompt` or an effect that builds one.
|
|
1323
|
+
* Effectful prompt creation is lazy and runs only when the fallback is needed.
|
|
1324
|
+
*
|
|
1325
|
+
* **Gotchas**
|
|
1326
|
+
*
|
|
1327
|
+
* This only handles missing options and missing arguments. Invalid values do not
|
|
1328
|
+
* prompt, and prompt cancellation re-fails with the original missing error.
|
|
1329
|
+
*
|
|
1330
|
+
* @see {@link FallbackPrompt} for accepted fallback prompt forms
|
|
1331
|
+
* @see {@link withFallbackConfig} for loading a fallback from config
|
|
1332
|
+
* @see {@link withDefault} for a pure default value
|
|
1333
|
+
*
|
|
1334
|
+
* @category combinators
|
|
1335
|
+
* @since 4.0.0
|
|
1336
|
+
*/
|
|
1337
|
+
<B>(prompt: FallbackPrompt<B>): <Kind extends ParamKind, A>(self: Param<Kind, A>) => Param<Kind, A | B>;
|
|
1338
|
+
/**
|
|
1339
|
+
* Adds a fallback prompt that is shown when a required parameter is missing.
|
|
1340
|
+
*
|
|
1341
|
+
* **When to use**
|
|
1342
|
+
*
|
|
1343
|
+
* Use when a CLI should ask interactively for a missing required flag or
|
|
1344
|
+
* argument.
|
|
1345
|
+
*
|
|
1346
|
+
* **Details**
|
|
1347
|
+
*
|
|
1348
|
+
* `FallbackPrompt` accepts either a `Prompt` or an effect that builds one.
|
|
1349
|
+
* Effectful prompt creation is lazy and runs only when the fallback is needed.
|
|
1350
|
+
*
|
|
1351
|
+
* **Gotchas**
|
|
1352
|
+
*
|
|
1353
|
+
* This only handles missing options and missing arguments. Invalid values do not
|
|
1354
|
+
* prompt, and prompt cancellation re-fails with the original missing error.
|
|
1355
|
+
*
|
|
1356
|
+
* @see {@link FallbackPrompt} for accepted fallback prompt forms
|
|
1357
|
+
* @see {@link withFallbackConfig} for loading a fallback from config
|
|
1358
|
+
* @see {@link withDefault} for a pure default value
|
|
1359
|
+
*
|
|
1360
|
+
* @category combinators
|
|
1361
|
+
* @since 4.0.0
|
|
1362
|
+
*/
|
|
1363
|
+
<Kind extends ParamKind, A, B>(self: Param<Kind, A>, prompt: FallbackPrompt<B>): Param<Kind, A | B>;
|
|
1364
|
+
};
|
|
1365
|
+
/**
|
|
1366
|
+
* Represent options which can be used to configure variadic parameters.
|
|
1367
|
+
*
|
|
1368
|
+
* @category options
|
|
1369
|
+
* @since 4.0.0
|
|
1370
|
+
*/
|
|
1371
|
+
export type VariadicParamOptions = {
|
|
1372
|
+
/**
|
|
1373
|
+
* The minimum number of times the parameter can be specified.
|
|
1374
|
+
*/
|
|
1375
|
+
readonly min?: number | undefined;
|
|
1376
|
+
/**
|
|
1377
|
+
* The maximum number of times the parameter can be specified.
|
|
1378
|
+
*/
|
|
1379
|
+
readonly max?: number | undefined;
|
|
1380
|
+
};
|
|
1381
|
+
/**
|
|
1382
|
+
* Creates a variadic parameter that can be specified multiple times.
|
|
1383
|
+
*
|
|
1384
|
+
* **Details**
|
|
1385
|
+
*
|
|
1386
|
+
* This is the base combinator for creating parameters that accept multiple values.
|
|
1387
|
+
* The `min` and `max` parameters are optional. When they are not provided, the
|
|
1388
|
+
* parameter can be specified any number of times, from 0 to infinity.
|
|
1389
|
+
*
|
|
1390
|
+
* **Example** (Accepting multiple values)
|
|
1391
|
+
*
|
|
1392
|
+
* ```ts
|
|
1393
|
+
* import { Param } from "effect/unstable/cli"
|
|
1394
|
+
*
|
|
1395
|
+
* // Basic variadic parameter (0 to infinity)
|
|
1396
|
+
* const tags = Param.variadic(Param.string(Param.flagKind, "tag"))
|
|
1397
|
+
*
|
|
1398
|
+
* // Variadic with minimum count
|
|
1399
|
+
* const inputs = Param.variadic(
|
|
1400
|
+
* Param.string(Param.flagKind, "input"),
|
|
1401
|
+
* { min: 1 } // at least 1 required
|
|
1402
|
+
* )
|
|
1403
|
+
*
|
|
1404
|
+
* // Variadic with both min and max
|
|
1405
|
+
* const limited = Param.variadic(Param.string(Param.flagKind, "item"), {
|
|
1406
|
+
* min: 2, // at least 2 times
|
|
1407
|
+
* max: 2 // at most 2 times
|
|
1408
|
+
* })
|
|
1409
|
+
* ```
|
|
1410
|
+
*
|
|
1411
|
+
* @category combinators
|
|
1412
|
+
* @since 4.0.0
|
|
1413
|
+
*/
|
|
1414
|
+
export declare const variadic: <Kind extends ParamKind, A>(self: Param<Kind, A>, options?: VariadicParamOptions | undefined) => Param<Kind, ReadonlyArray<A>>;
|
|
1415
|
+
/**
|
|
1416
|
+
* Wraps an option to allow it to be specified multiple times within a range.
|
|
1417
|
+
*
|
|
1418
|
+
* **Details**
|
|
1419
|
+
*
|
|
1420
|
+
* This combinator transforms an option to accept between `min` and `max`
|
|
1421
|
+
* occurrences on the command line, returning an array of all provided values.
|
|
1422
|
+
*
|
|
1423
|
+
* **Example** (Bounding repeated values)
|
|
1424
|
+
*
|
|
1425
|
+
* ```ts
|
|
1426
|
+
* import { Param } from "effect/unstable/cli"
|
|
1427
|
+
*
|
|
1428
|
+
* // Allow 1-3 file inputs
|
|
1429
|
+
* const files = Param.string(Param.flagKind, "file").pipe(
|
|
1430
|
+
* Param.between(1, 3),
|
|
1431
|
+
* Param.withAlias("-f")
|
|
1432
|
+
* )
|
|
1433
|
+
*
|
|
1434
|
+
* // Parse: --file a.txt --file b.txt
|
|
1435
|
+
* // Result: ["a.txt", "b.txt"]
|
|
1436
|
+
*
|
|
1437
|
+
* // Allow 0 or more tags
|
|
1438
|
+
* const tags = Param.string(Param.flagKind, "tag").pipe(
|
|
1439
|
+
* Param.between(0, Number.MAX_SAFE_INTEGER)
|
|
1440
|
+
* )
|
|
1441
|
+
*
|
|
1442
|
+
* // Parse: --tag dev --tag staging --tag v1.0
|
|
1443
|
+
* // Result: ["dev", "staging", "v1.0"]
|
|
1444
|
+
* ```
|
|
1445
|
+
*
|
|
1446
|
+
* @category combinators
|
|
1447
|
+
* @since 4.0.0
|
|
1448
|
+
*/
|
|
1449
|
+
export declare const between: {
|
|
1450
|
+
/**
|
|
1451
|
+
* Wraps an option to allow it to be specified multiple times within a range.
|
|
1452
|
+
*
|
|
1453
|
+
* **Details**
|
|
1454
|
+
*
|
|
1455
|
+
* This combinator transforms an option to accept between `min` and `max`
|
|
1456
|
+
* occurrences on the command line, returning an array of all provided values.
|
|
1457
|
+
*
|
|
1458
|
+
* **Example** (Bounding repeated values)
|
|
1459
|
+
*
|
|
1460
|
+
* ```ts
|
|
1461
|
+
* import { Param } from "effect/unstable/cli"
|
|
1462
|
+
*
|
|
1463
|
+
* // Allow 1-3 file inputs
|
|
1464
|
+
* const files = Param.string(Param.flagKind, "file").pipe(
|
|
1465
|
+
* Param.between(1, 3),
|
|
1466
|
+
* Param.withAlias("-f")
|
|
1467
|
+
* )
|
|
1468
|
+
*
|
|
1469
|
+
* // Parse: --file a.txt --file b.txt
|
|
1470
|
+
* // Result: ["a.txt", "b.txt"]
|
|
1471
|
+
*
|
|
1472
|
+
* // Allow 0 or more tags
|
|
1473
|
+
* const tags = Param.string(Param.flagKind, "tag").pipe(
|
|
1474
|
+
* Param.between(0, Number.MAX_SAFE_INTEGER)
|
|
1475
|
+
* )
|
|
1476
|
+
*
|
|
1477
|
+
* // Parse: --tag dev --tag staging --tag v1.0
|
|
1478
|
+
* // Result: ["dev", "staging", "v1.0"]
|
|
1479
|
+
* ```
|
|
1480
|
+
*
|
|
1481
|
+
* @category combinators
|
|
1482
|
+
* @since 4.0.0
|
|
1483
|
+
*/
|
|
1484
|
+
<A>(min: number, max: number): <Kind extends ParamKind>(self: Param<Kind, A>) => Param<Kind, ReadonlyArray<A>>;
|
|
1485
|
+
/**
|
|
1486
|
+
* Wraps an option to allow it to be specified multiple times within a range.
|
|
1487
|
+
*
|
|
1488
|
+
* **Details**
|
|
1489
|
+
*
|
|
1490
|
+
* This combinator transforms an option to accept between `min` and `max`
|
|
1491
|
+
* occurrences on the command line, returning an array of all provided values.
|
|
1492
|
+
*
|
|
1493
|
+
* **Example** (Bounding repeated values)
|
|
1494
|
+
*
|
|
1495
|
+
* ```ts
|
|
1496
|
+
* import { Param } from "effect/unstable/cli"
|
|
1497
|
+
*
|
|
1498
|
+
* // Allow 1-3 file inputs
|
|
1499
|
+
* const files = Param.string(Param.flagKind, "file").pipe(
|
|
1500
|
+
* Param.between(1, 3),
|
|
1501
|
+
* Param.withAlias("-f")
|
|
1502
|
+
* )
|
|
1503
|
+
*
|
|
1504
|
+
* // Parse: --file a.txt --file b.txt
|
|
1505
|
+
* // Result: ["a.txt", "b.txt"]
|
|
1506
|
+
*
|
|
1507
|
+
* // Allow 0 or more tags
|
|
1508
|
+
* const tags = Param.string(Param.flagKind, "tag").pipe(
|
|
1509
|
+
* Param.between(0, Number.MAX_SAFE_INTEGER)
|
|
1510
|
+
* )
|
|
1511
|
+
*
|
|
1512
|
+
* // Parse: --tag dev --tag staging --tag v1.0
|
|
1513
|
+
* // Result: ["dev", "staging", "v1.0"]
|
|
1514
|
+
* ```
|
|
1515
|
+
*
|
|
1516
|
+
* @category combinators
|
|
1517
|
+
* @since 4.0.0
|
|
1518
|
+
*/
|
|
1519
|
+
<Kind extends ParamKind, A>(self: Param<Kind, A>, min: number, max: number): Param<Kind, ReadonlyArray<A>>;
|
|
1520
|
+
};
|
|
1521
|
+
/**
|
|
1522
|
+
* Wraps an option to allow it to be specified at most `max` times.
|
|
1523
|
+
*
|
|
1524
|
+
* **Details**
|
|
1525
|
+
*
|
|
1526
|
+
* This combinator transforms an option to accept between 0 and `max`
|
|
1527
|
+
* occurrences on the command line, returning an array of all provided values.
|
|
1528
|
+
*
|
|
1529
|
+
* **Example** (Limiting repeated values)
|
|
1530
|
+
*
|
|
1531
|
+
* ```ts
|
|
1532
|
+
* import { Param } from "effect/unstable/cli"
|
|
1533
|
+
*
|
|
1534
|
+
* // Allow at most 3 warning suppressions
|
|
1535
|
+
* const suppressions = Param.string(Param.flagKind, "suppress").pipe(
|
|
1536
|
+
* Param.atMost(3)
|
|
1537
|
+
* )
|
|
1538
|
+
*
|
|
1539
|
+
* // Parse: --suppress warning1 --suppress warning2
|
|
1540
|
+
* // Result: ["warning1", "warning2"]
|
|
1541
|
+
* ```
|
|
1542
|
+
*
|
|
1543
|
+
* @category combinators
|
|
1544
|
+
* @since 4.0.0
|
|
1545
|
+
*/
|
|
1546
|
+
export declare const atMost: {
|
|
1547
|
+
/**
|
|
1548
|
+
* Wraps an option to allow it to be specified at most `max` times.
|
|
1549
|
+
*
|
|
1550
|
+
* **Details**
|
|
1551
|
+
*
|
|
1552
|
+
* This combinator transforms an option to accept between 0 and `max`
|
|
1553
|
+
* occurrences on the command line, returning an array of all provided values.
|
|
1554
|
+
*
|
|
1555
|
+
* **Example** (Limiting repeated values)
|
|
1556
|
+
*
|
|
1557
|
+
* ```ts
|
|
1558
|
+
* import { Param } from "effect/unstable/cli"
|
|
1559
|
+
*
|
|
1560
|
+
* // Allow at most 3 warning suppressions
|
|
1561
|
+
* const suppressions = Param.string(Param.flagKind, "suppress").pipe(
|
|
1562
|
+
* Param.atMost(3)
|
|
1563
|
+
* )
|
|
1564
|
+
*
|
|
1565
|
+
* // Parse: --suppress warning1 --suppress warning2
|
|
1566
|
+
* // Result: ["warning1", "warning2"]
|
|
1567
|
+
* ```
|
|
1568
|
+
*
|
|
1569
|
+
* @category combinators
|
|
1570
|
+
* @since 4.0.0
|
|
1571
|
+
*/
|
|
1572
|
+
<A>(max: number): <Kind extends ParamKind>(self: Param<Kind, A>) => Param<Kind, ReadonlyArray<A>>;
|
|
1573
|
+
/**
|
|
1574
|
+
* Wraps an option to allow it to be specified at most `max` times.
|
|
1575
|
+
*
|
|
1576
|
+
* **Details**
|
|
1577
|
+
*
|
|
1578
|
+
* This combinator transforms an option to accept between 0 and `max`
|
|
1579
|
+
* occurrences on the command line, returning an array of all provided values.
|
|
1580
|
+
*
|
|
1581
|
+
* **Example** (Limiting repeated values)
|
|
1582
|
+
*
|
|
1583
|
+
* ```ts
|
|
1584
|
+
* import { Param } from "effect/unstable/cli"
|
|
1585
|
+
*
|
|
1586
|
+
* // Allow at most 3 warning suppressions
|
|
1587
|
+
* const suppressions = Param.string(Param.flagKind, "suppress").pipe(
|
|
1588
|
+
* Param.atMost(3)
|
|
1589
|
+
* )
|
|
1590
|
+
*
|
|
1591
|
+
* // Parse: --suppress warning1 --suppress warning2
|
|
1592
|
+
* // Result: ["warning1", "warning2"]
|
|
1593
|
+
* ```
|
|
1594
|
+
*
|
|
1595
|
+
* @category combinators
|
|
1596
|
+
* @since 4.0.0
|
|
1597
|
+
*/
|
|
1598
|
+
<Kind extends ParamKind, A>(self: Param<Kind, A>, max: number): Param<Kind, ReadonlyArray<A>>;
|
|
1599
|
+
};
|
|
1600
|
+
/**
|
|
1601
|
+
* Wraps an option to require it to be specified at least `min` times.
|
|
1602
|
+
*
|
|
1603
|
+
* **Details**
|
|
1604
|
+
*
|
|
1605
|
+
* This combinator transforms an option to accept at least `min`
|
|
1606
|
+
* occurrences on the command line, returning an array of all provided values.
|
|
1607
|
+
*
|
|
1608
|
+
* **Example** (Requiring repeated values)
|
|
1609
|
+
*
|
|
1610
|
+
* ```ts
|
|
1611
|
+
* import { Param } from "effect/unstable/cli"
|
|
1612
|
+
*
|
|
1613
|
+
* // Require at least 2 input files
|
|
1614
|
+
* const inputs = Param.string(Param.flagKind, "input").pipe(
|
|
1615
|
+
* Param.atLeast(2),
|
|
1616
|
+
* Param.withAlias("-i")
|
|
1617
|
+
* )
|
|
1618
|
+
*
|
|
1619
|
+
* // Parse: --input file1.txt --input file2.txt --input file3.txt
|
|
1620
|
+
* // Result: ["file1.txt", "file2.txt", "file3.txt"]
|
|
1621
|
+
* ```
|
|
1622
|
+
*
|
|
1623
|
+
* @category combinators
|
|
1624
|
+
* @since 4.0.0
|
|
1625
|
+
*/
|
|
1626
|
+
export declare const atLeast: {
|
|
1627
|
+
/**
|
|
1628
|
+
* Wraps an option to require it to be specified at least `min` times.
|
|
1629
|
+
*
|
|
1630
|
+
* **Details**
|
|
1631
|
+
*
|
|
1632
|
+
* This combinator transforms an option to accept at least `min`
|
|
1633
|
+
* occurrences on the command line, returning an array of all provided values.
|
|
1634
|
+
*
|
|
1635
|
+
* **Example** (Requiring repeated values)
|
|
1636
|
+
*
|
|
1637
|
+
* ```ts
|
|
1638
|
+
* import { Param } from "effect/unstable/cli"
|
|
1639
|
+
*
|
|
1640
|
+
* // Require at least 2 input files
|
|
1641
|
+
* const inputs = Param.string(Param.flagKind, "input").pipe(
|
|
1642
|
+
* Param.atLeast(2),
|
|
1643
|
+
* Param.withAlias("-i")
|
|
1644
|
+
* )
|
|
1645
|
+
*
|
|
1646
|
+
* // Parse: --input file1.txt --input file2.txt --input file3.txt
|
|
1647
|
+
* // Result: ["file1.txt", "file2.txt", "file3.txt"]
|
|
1648
|
+
* ```
|
|
1649
|
+
*
|
|
1650
|
+
* @category combinators
|
|
1651
|
+
* @since 4.0.0
|
|
1652
|
+
*/
|
|
1653
|
+
<A>(min: number): <Kind extends ParamKind>(self: Param<Kind, A>) => Param<Kind, ReadonlyArray<A>>;
|
|
1654
|
+
/**
|
|
1655
|
+
* Wraps an option to require it to be specified at least `min` times.
|
|
1656
|
+
*
|
|
1657
|
+
* **Details**
|
|
1658
|
+
*
|
|
1659
|
+
* This combinator transforms an option to accept at least `min`
|
|
1660
|
+
* occurrences on the command line, returning an array of all provided values.
|
|
1661
|
+
*
|
|
1662
|
+
* **Example** (Requiring repeated values)
|
|
1663
|
+
*
|
|
1664
|
+
* ```ts
|
|
1665
|
+
* import { Param } from "effect/unstable/cli"
|
|
1666
|
+
*
|
|
1667
|
+
* // Require at least 2 input files
|
|
1668
|
+
* const inputs = Param.string(Param.flagKind, "input").pipe(
|
|
1669
|
+
* Param.atLeast(2),
|
|
1670
|
+
* Param.withAlias("-i")
|
|
1671
|
+
* )
|
|
1672
|
+
*
|
|
1673
|
+
* // Parse: --input file1.txt --input file2.txt --input file3.txt
|
|
1674
|
+
* // Result: ["file1.txt", "file2.txt", "file3.txt"]
|
|
1675
|
+
* ```
|
|
1676
|
+
*
|
|
1677
|
+
* @category combinators
|
|
1678
|
+
* @since 4.0.0
|
|
1679
|
+
*/
|
|
1680
|
+
<Kind extends ParamKind, A>(self: Param<Kind, A>, min: number): Param<Kind, ReadonlyArray<A>>;
|
|
1681
|
+
};
|
|
1682
|
+
/**
|
|
1683
|
+
* Filters and transforms parsed values, failing with a custom error message
|
|
1684
|
+
* if the filter function returns `Option.none()`.
|
|
1685
|
+
*
|
|
1686
|
+
* **When to use**
|
|
1687
|
+
*
|
|
1688
|
+
* Use when you need validation and transformation in a single parameter
|
|
1689
|
+
* combinator.
|
|
1690
|
+
*
|
|
1691
|
+
* **Example** (Filtering and transforming values)
|
|
1692
|
+
*
|
|
1693
|
+
* ```ts
|
|
1694
|
+
* import { Option } from "effect"
|
|
1695
|
+
* import { Param } from "effect/unstable/cli"
|
|
1696
|
+
* const positiveInt = Param.integer(Param.flagKind, "count").pipe(
|
|
1697
|
+
* Param.filterMap(
|
|
1698
|
+
* (n) => n > 0 ? Option.some(n) : Option.none(),
|
|
1699
|
+
* (n) => `Expected positive integer, got ${n}`
|
|
1700
|
+
* )
|
|
1701
|
+
* )
|
|
1702
|
+
* ```
|
|
1703
|
+
*
|
|
1704
|
+
* @category combinators
|
|
1705
|
+
* @since 4.0.0
|
|
1706
|
+
*/
|
|
1707
|
+
export declare const filterMap: {
|
|
1708
|
+
/**
|
|
1709
|
+
* Filters and transforms parsed values, failing with a custom error message
|
|
1710
|
+
* if the filter function returns `Option.none()`.
|
|
1711
|
+
*
|
|
1712
|
+
* **When to use**
|
|
1713
|
+
*
|
|
1714
|
+
* Use when you need validation and transformation in a single parameter
|
|
1715
|
+
* combinator.
|
|
1716
|
+
*
|
|
1717
|
+
* **Example** (Filtering and transforming values)
|
|
1718
|
+
*
|
|
1719
|
+
* ```ts
|
|
1720
|
+
* import { Option } from "effect"
|
|
1721
|
+
* import { Param } from "effect/unstable/cli"
|
|
1722
|
+
* const positiveInt = Param.integer(Param.flagKind, "count").pipe(
|
|
1723
|
+
* Param.filterMap(
|
|
1724
|
+
* (n) => n > 0 ? Option.some(n) : Option.none(),
|
|
1725
|
+
* (n) => `Expected positive integer, got ${n}`
|
|
1726
|
+
* )
|
|
1727
|
+
* )
|
|
1728
|
+
* ```
|
|
1729
|
+
*
|
|
1730
|
+
* @category combinators
|
|
1731
|
+
* @since 4.0.0
|
|
1732
|
+
*/
|
|
1733
|
+
<A, B>(filter: (a: A) => Option.Option<B>, onNone: (a: A) => string): <Kind extends ParamKind>(self: Param<Kind, A>) => Param<Kind, B>;
|
|
1734
|
+
/**
|
|
1735
|
+
* Filters and transforms parsed values, failing with a custom error message
|
|
1736
|
+
* if the filter function returns `Option.none()`.
|
|
1737
|
+
*
|
|
1738
|
+
* **When to use**
|
|
1739
|
+
*
|
|
1740
|
+
* Use when you need validation and transformation in a single parameter
|
|
1741
|
+
* combinator.
|
|
1742
|
+
*
|
|
1743
|
+
* **Example** (Filtering and transforming values)
|
|
1744
|
+
*
|
|
1745
|
+
* ```ts
|
|
1746
|
+
* import { Option } from "effect"
|
|
1747
|
+
* import { Param } from "effect/unstable/cli"
|
|
1748
|
+
* const positiveInt = Param.integer(Param.flagKind, "count").pipe(
|
|
1749
|
+
* Param.filterMap(
|
|
1750
|
+
* (n) => n > 0 ? Option.some(n) : Option.none(),
|
|
1751
|
+
* (n) => `Expected positive integer, got ${n}`
|
|
1752
|
+
* )
|
|
1753
|
+
* )
|
|
1754
|
+
* ```
|
|
1755
|
+
*
|
|
1756
|
+
* @category combinators
|
|
1757
|
+
* @since 4.0.0
|
|
1758
|
+
*/
|
|
1759
|
+
<Kind extends ParamKind, A, B>(self: Param<Kind, A>, filter: (a: A) => Option.Option<B>, onNone: (a: A) => string): Param<Kind, B>;
|
|
1760
|
+
};
|
|
1761
|
+
/**
|
|
1762
|
+
* Filters parsed values, failing with a custom error message if the predicate returns false.
|
|
1763
|
+
*
|
|
1764
|
+
* **Example** (Filtering parsed values)
|
|
1765
|
+
*
|
|
1766
|
+
* ```ts
|
|
1767
|
+
* import { Param } from "effect/unstable/cli"
|
|
1768
|
+
*
|
|
1769
|
+
* const evenNumber = Param.integer(Param.flagKind, "num").pipe(
|
|
1770
|
+
* Param.filter(
|
|
1771
|
+
* (n) => n % 2 === 0,
|
|
1772
|
+
* (n) => `Expected even number, got ${n}`
|
|
1773
|
+
* )
|
|
1774
|
+
* )
|
|
1775
|
+
* ```
|
|
1776
|
+
*
|
|
1777
|
+
* @category combinators
|
|
1778
|
+
* @since 4.0.0
|
|
1779
|
+
*/
|
|
1780
|
+
export declare const filter: {
|
|
1781
|
+
/**
|
|
1782
|
+
* Filters parsed values, failing with a custom error message if the predicate returns false.
|
|
1783
|
+
*
|
|
1784
|
+
* **Example** (Filtering parsed values)
|
|
1785
|
+
*
|
|
1786
|
+
* ```ts
|
|
1787
|
+
* import { Param } from "effect/unstable/cli"
|
|
1788
|
+
*
|
|
1789
|
+
* const evenNumber = Param.integer(Param.flagKind, "num").pipe(
|
|
1790
|
+
* Param.filter(
|
|
1791
|
+
* (n) => n % 2 === 0,
|
|
1792
|
+
* (n) => `Expected even number, got ${n}`
|
|
1793
|
+
* )
|
|
1794
|
+
* )
|
|
1795
|
+
* ```
|
|
1796
|
+
*
|
|
1797
|
+
* @category combinators
|
|
1798
|
+
* @since 4.0.0
|
|
1799
|
+
*/
|
|
1800
|
+
<A>(predicate: Predicate.Predicate<A>, onFalse: (a: A) => string): <Kind extends ParamKind>(self: Param<Kind, A>) => Param<Kind, A>;
|
|
1801
|
+
/**
|
|
1802
|
+
* Filters parsed values, failing with a custom error message if the predicate returns false.
|
|
1803
|
+
*
|
|
1804
|
+
* **Example** (Filtering parsed values)
|
|
1805
|
+
*
|
|
1806
|
+
* ```ts
|
|
1807
|
+
* import { Param } from "effect/unstable/cli"
|
|
1808
|
+
*
|
|
1809
|
+
* const evenNumber = Param.integer(Param.flagKind, "num").pipe(
|
|
1810
|
+
* Param.filter(
|
|
1811
|
+
* (n) => n % 2 === 0,
|
|
1812
|
+
* (n) => `Expected even number, got ${n}`
|
|
1813
|
+
* )
|
|
1814
|
+
* )
|
|
1815
|
+
* ```
|
|
1816
|
+
*
|
|
1817
|
+
* @category combinators
|
|
1818
|
+
* @since 4.0.0
|
|
1819
|
+
*/
|
|
1820
|
+
<Kind extends ParamKind, A>(self: Param<Kind, A>, predicate: Predicate.Predicate<A>, onFalse: (a: A) => string): Param<Kind, A>;
|
|
1821
|
+
};
|
|
1822
|
+
/**
|
|
1823
|
+
* Sets a custom metavar (placeholder name) for the param in help documentation.
|
|
1824
|
+
*
|
|
1825
|
+
* **Details**
|
|
1826
|
+
*
|
|
1827
|
+
* The metavar is displayed in usage text to indicate what value the user should provide.
|
|
1828
|
+
* For example, `--output FILE` shows `FILE` as the metavar.
|
|
1829
|
+
*
|
|
1830
|
+
* **Example** (Setting metavars)
|
|
1831
|
+
*
|
|
1832
|
+
* ```ts
|
|
1833
|
+
* import { Param } from "effect/unstable/cli"
|
|
1834
|
+
*
|
|
1835
|
+
* const port = Param.integer(Param.flagKind, "port").pipe(
|
|
1836
|
+
* Param.withMetavar("PORT"),
|
|
1837
|
+
* Param.filter(
|
|
1838
|
+
* (p) => p >= 1 && p <= 65535,
|
|
1839
|
+
* () => "Port must be between 1 and 65535"
|
|
1840
|
+
* )
|
|
1841
|
+
* )
|
|
1842
|
+
* ```
|
|
1843
|
+
*
|
|
1844
|
+
* @category metadata
|
|
1845
|
+
* @since 4.0.0
|
|
1846
|
+
*/
|
|
1847
|
+
export declare const withMetavar: {
|
|
1848
|
+
/**
|
|
1849
|
+
* Sets a custom metavar (placeholder name) for the param in help documentation.
|
|
1850
|
+
*
|
|
1851
|
+
* **Details**
|
|
1852
|
+
*
|
|
1853
|
+
* The metavar is displayed in usage text to indicate what value the user should provide.
|
|
1854
|
+
* For example, `--output FILE` shows `FILE` as the metavar.
|
|
1855
|
+
*
|
|
1856
|
+
* **Example** (Setting metavars)
|
|
1857
|
+
*
|
|
1858
|
+
* ```ts
|
|
1859
|
+
* import { Param } from "effect/unstable/cli"
|
|
1860
|
+
*
|
|
1861
|
+
* const port = Param.integer(Param.flagKind, "port").pipe(
|
|
1862
|
+
* Param.withMetavar("PORT"),
|
|
1863
|
+
* Param.filter(
|
|
1864
|
+
* (p) => p >= 1 && p <= 65535,
|
|
1865
|
+
* () => "Port must be between 1 and 65535"
|
|
1866
|
+
* )
|
|
1867
|
+
* )
|
|
1868
|
+
* ```
|
|
1869
|
+
*
|
|
1870
|
+
* @category metadata
|
|
1871
|
+
* @since 4.0.0
|
|
1872
|
+
*/
|
|
1873
|
+
<K extends ParamKind>(metavar: string): <A>(self: Param<K, A>) => Param<K, A>;
|
|
1874
|
+
/**
|
|
1875
|
+
* Sets a custom metavar (placeholder name) for the param in help documentation.
|
|
1876
|
+
*
|
|
1877
|
+
* **Details**
|
|
1878
|
+
*
|
|
1879
|
+
* The metavar is displayed in usage text to indicate what value the user should provide.
|
|
1880
|
+
* For example, `--output FILE` shows `FILE` as the metavar.
|
|
1881
|
+
*
|
|
1882
|
+
* **Example** (Setting metavars)
|
|
1883
|
+
*
|
|
1884
|
+
* ```ts
|
|
1885
|
+
* import { Param } from "effect/unstable/cli"
|
|
1886
|
+
*
|
|
1887
|
+
* const port = Param.integer(Param.flagKind, "port").pipe(
|
|
1888
|
+
* Param.withMetavar("PORT"),
|
|
1889
|
+
* Param.filter(
|
|
1890
|
+
* (p) => p >= 1 && p <= 65535,
|
|
1891
|
+
* () => "Port must be between 1 and 65535"
|
|
1892
|
+
* )
|
|
1893
|
+
* )
|
|
1894
|
+
* ```
|
|
1895
|
+
*
|
|
1896
|
+
* @category metadata
|
|
1897
|
+
* @since 4.0.0
|
|
1898
|
+
*/
|
|
1899
|
+
<K extends ParamKind, A>(self: Param<K, A>, metavar: string): Param<K, A>;
|
|
1900
|
+
};
|
|
1901
|
+
/**
|
|
1902
|
+
* Validates parsed values against a Schema, providing detailed error messages.
|
|
1903
|
+
*
|
|
1904
|
+
* **Example** (Validating with schemas)
|
|
1905
|
+
*
|
|
1906
|
+
* ```ts
|
|
1907
|
+
* import { Schema } from "effect"
|
|
1908
|
+
* import { Param } from "effect/unstable/cli"
|
|
1909
|
+
* const isEmail = Schema.isPattern(/^[^\s@]+@[^\s@]+\.[^\s@]+$/)
|
|
1910
|
+
*
|
|
1911
|
+
* const Email = Schema.String.pipe(
|
|
1912
|
+
* Schema.check(isEmail)
|
|
1913
|
+
* )
|
|
1914
|
+
*
|
|
1915
|
+
* const email = Param.string(Param.flagKind, "email").pipe(
|
|
1916
|
+
* Param.withSchema(Email)
|
|
1917
|
+
* )
|
|
1918
|
+
* ```
|
|
1919
|
+
*
|
|
1920
|
+
* @category combinators
|
|
1921
|
+
* @since 4.0.0
|
|
1922
|
+
*/
|
|
1923
|
+
export declare const withSchema: {
|
|
1924
|
+
/**
|
|
1925
|
+
* Validates parsed values against a Schema, providing detailed error messages.
|
|
1926
|
+
*
|
|
1927
|
+
* **Example** (Validating with schemas)
|
|
1928
|
+
*
|
|
1929
|
+
* ```ts
|
|
1930
|
+
* import { Schema } from "effect"
|
|
1931
|
+
* import { Param } from "effect/unstable/cli"
|
|
1932
|
+
* const isEmail = Schema.isPattern(/^[^\s@]+@[^\s@]+\.[^\s@]+$/)
|
|
1933
|
+
*
|
|
1934
|
+
* const Email = Schema.String.pipe(
|
|
1935
|
+
* Schema.check(isEmail)
|
|
1936
|
+
* )
|
|
1937
|
+
*
|
|
1938
|
+
* const email = Param.string(Param.flagKind, "email").pipe(
|
|
1939
|
+
* Param.withSchema(Email)
|
|
1940
|
+
* )
|
|
1941
|
+
* ```
|
|
1942
|
+
*
|
|
1943
|
+
* @category combinators
|
|
1944
|
+
* @since 4.0.0
|
|
1945
|
+
*/
|
|
1946
|
+
<A, B>(schema: Schema.Codec<B, A, Environment, Environment>): <Kind extends ParamKind>(self: Param<Kind, A>) => Param<Kind, B>;
|
|
1947
|
+
/**
|
|
1948
|
+
* Validates parsed values against a Schema, providing detailed error messages.
|
|
1949
|
+
*
|
|
1950
|
+
* **Example** (Validating with schemas)
|
|
1951
|
+
*
|
|
1952
|
+
* ```ts
|
|
1953
|
+
* import { Schema } from "effect"
|
|
1954
|
+
* import { Param } from "effect/unstable/cli"
|
|
1955
|
+
* const isEmail = Schema.isPattern(/^[^\s@]+@[^\s@]+\.[^\s@]+$/)
|
|
1956
|
+
*
|
|
1957
|
+
* const Email = Schema.String.pipe(
|
|
1958
|
+
* Schema.check(isEmail)
|
|
1959
|
+
* )
|
|
1960
|
+
*
|
|
1961
|
+
* const email = Param.string(Param.flagKind, "email").pipe(
|
|
1962
|
+
* Param.withSchema(Email)
|
|
1963
|
+
* )
|
|
1964
|
+
* ```
|
|
1965
|
+
*
|
|
1966
|
+
* @category combinators
|
|
1967
|
+
* @since 4.0.0
|
|
1968
|
+
*/
|
|
1969
|
+
<Kind extends ParamKind, A, B>(self: Param<Kind, A>, schema: Schema.Codec<B, A, Environment, Environment>): Param<Kind, B>;
|
|
1970
|
+
};
|
|
1971
|
+
/**
|
|
1972
|
+
* Provides a fallback param to use if this param fails to parse.
|
|
1973
|
+
*
|
|
1974
|
+
* **Example** (Falling back to another parameter)
|
|
1975
|
+
*
|
|
1976
|
+
* ```ts
|
|
1977
|
+
* import { Param } from "effect/unstable/cli"
|
|
1978
|
+
*
|
|
1979
|
+
* const config = Param.file(Param.flagKind, "config").pipe(
|
|
1980
|
+
* Param.orElse(() => Param.string(Param.flagKind, "config-url"))
|
|
1981
|
+
* )
|
|
1982
|
+
* ```
|
|
1983
|
+
*
|
|
1984
|
+
* @category combinators
|
|
1985
|
+
* @since 4.0.0
|
|
1986
|
+
*/
|
|
1987
|
+
export declare const orElse: {
|
|
1988
|
+
/**
|
|
1989
|
+
* Provides a fallback param to use if this param fails to parse.
|
|
1990
|
+
*
|
|
1991
|
+
* **Example** (Falling back to another parameter)
|
|
1992
|
+
*
|
|
1993
|
+
* ```ts
|
|
1994
|
+
* import { Param } from "effect/unstable/cli"
|
|
1995
|
+
*
|
|
1996
|
+
* const config = Param.file(Param.flagKind, "config").pipe(
|
|
1997
|
+
* Param.orElse(() => Param.string(Param.flagKind, "config-url"))
|
|
1998
|
+
* )
|
|
1999
|
+
* ```
|
|
2000
|
+
*
|
|
2001
|
+
* @category combinators
|
|
2002
|
+
* @since 4.0.0
|
|
2003
|
+
*/
|
|
2004
|
+
<B, Kind extends ParamKind>(orElse: (error: CliError.CliError) => Param<Kind, B>): <A>(self: Param<Kind, A>) => Param<Kind, A | B>;
|
|
2005
|
+
/**
|
|
2006
|
+
* Provides a fallback param to use if this param fails to parse.
|
|
2007
|
+
*
|
|
2008
|
+
* **Example** (Falling back to another parameter)
|
|
2009
|
+
*
|
|
2010
|
+
* ```ts
|
|
2011
|
+
* import { Param } from "effect/unstable/cli"
|
|
2012
|
+
*
|
|
2013
|
+
* const config = Param.file(Param.flagKind, "config").pipe(
|
|
2014
|
+
* Param.orElse(() => Param.string(Param.flagKind, "config-url"))
|
|
2015
|
+
* )
|
|
2016
|
+
* ```
|
|
2017
|
+
*
|
|
2018
|
+
* @category combinators
|
|
2019
|
+
* @since 4.0.0
|
|
2020
|
+
*/
|
|
2021
|
+
<Kind extends ParamKind, A, B>(self: Param<Kind, A>, orElse: (error: CliError.CliError) => Param<Kind, B>): Param<Kind, A | B>;
|
|
2022
|
+
};
|
|
2023
|
+
/**
|
|
2024
|
+
* Provides a fallback param and returns a `Result` indicating which param
|
|
2025
|
+
* succeeded.
|
|
2026
|
+
*
|
|
2027
|
+
* **Details**
|
|
2028
|
+
*
|
|
2029
|
+
* The original param's value is returned as `Result.succeed`, while the
|
|
2030
|
+
* fallback param's value is returned as `Result.fail`.
|
|
2031
|
+
*
|
|
2032
|
+
* **Example** (Returning fallback results)
|
|
2033
|
+
*
|
|
2034
|
+
* ```ts
|
|
2035
|
+
* import { Param } from "effect/unstable/cli"
|
|
2036
|
+
*
|
|
2037
|
+
* const configSource = Param.file(Param.flagKind, "config").pipe(
|
|
2038
|
+
* Param.orElseResult(() => Param.string(Param.flagKind, "config-url"))
|
|
2039
|
+
* )
|
|
2040
|
+
* // Returns Result<string, string>
|
|
2041
|
+
* ```
|
|
2042
|
+
*
|
|
2043
|
+
* @category combinators
|
|
2044
|
+
* @since 4.0.0
|
|
2045
|
+
*/
|
|
2046
|
+
export declare const orElseResult: {
|
|
2047
|
+
/**
|
|
2048
|
+
* Provides a fallback param and returns a `Result` indicating which param
|
|
2049
|
+
* succeeded.
|
|
2050
|
+
*
|
|
2051
|
+
* **Details**
|
|
2052
|
+
*
|
|
2053
|
+
* The original param's value is returned as `Result.succeed`, while the
|
|
2054
|
+
* fallback param's value is returned as `Result.fail`.
|
|
2055
|
+
*
|
|
2056
|
+
* **Example** (Returning fallback results)
|
|
2057
|
+
*
|
|
2058
|
+
* ```ts
|
|
2059
|
+
* import { Param } from "effect/unstable/cli"
|
|
2060
|
+
*
|
|
2061
|
+
* const configSource = Param.file(Param.flagKind, "config").pipe(
|
|
2062
|
+
* Param.orElseResult(() => Param.string(Param.flagKind, "config-url"))
|
|
2063
|
+
* )
|
|
2064
|
+
* // Returns Result<string, string>
|
|
2065
|
+
* ```
|
|
2066
|
+
*
|
|
2067
|
+
* @category combinators
|
|
2068
|
+
* @since 4.0.0
|
|
2069
|
+
*/
|
|
2070
|
+
<Kind extends ParamKind, B>(orElse: (error: CliError.CliError) => Param<Kind, B>): <A>(self: Param<Kind, A>) => Param<Kind, Result.Result<A, B>>;
|
|
2071
|
+
/**
|
|
2072
|
+
* Provides a fallback param and returns a `Result` indicating which param
|
|
2073
|
+
* succeeded.
|
|
2074
|
+
*
|
|
2075
|
+
* **Details**
|
|
2076
|
+
*
|
|
2077
|
+
* The original param's value is returned as `Result.succeed`, while the
|
|
2078
|
+
* fallback param's value is returned as `Result.fail`.
|
|
2079
|
+
*
|
|
2080
|
+
* **Example** (Returning fallback results)
|
|
2081
|
+
*
|
|
2082
|
+
* ```ts
|
|
2083
|
+
* import { Param } from "effect/unstable/cli"
|
|
2084
|
+
*
|
|
2085
|
+
* const configSource = Param.file(Param.flagKind, "config").pipe(
|
|
2086
|
+
* Param.orElseResult(() => Param.string(Param.flagKind, "config-url"))
|
|
2087
|
+
* )
|
|
2088
|
+
* // Returns Result<string, string>
|
|
2089
|
+
* ```
|
|
2090
|
+
*
|
|
2091
|
+
* @category combinators
|
|
2092
|
+
* @since 4.0.0
|
|
2093
|
+
*/
|
|
2094
|
+
<Kind extends ParamKind, A, B>(self: Param<Kind, A>, orElse: (error: CliError.CliError) => Param<Kind, B>): Param<Kind, Result.Result<A, B>>;
|
|
457
2095
|
};
|
|
458
2096
|
export {};
|
|
459
2097
|
//# sourceMappingURL=Param.d.ts.map
|