Options
Combinators
Signature
declare const atLeast: {
(times: 0): <A>(self: Options<A>) => Options<Array<A>>;
(times: number): <A>(self: Options<A>) => Options<[A, ...Array<A>]>;
<A>(self: Options<A>, times: 0): Options<Array<A>>;
<A>(self: Options<A>, times: number): Options<[A, ...Array<A>]>;
};Signature
declare const atMost: {
(times: number): <A>(self: Options<A>) => Options<Array<A>>;
<A>(self: Options<A>, times: number): Options<Array<A>>;
};Signature
declare const between: {
(min: 0, max: number): <A>(self: Options<A>) => Options<Array<A>>;
(min: number, max: number): <A>(self: Options<A>) => Options<[A, ...Array<A>]>;
<A>(self: Options<A>, min: 0, max: number): Options<Array<A>>;
<A>(self: Options<A>, min: number, max: number): Options<[A, ...Array<A>]>;
};Signature
declare const filterMap: {
<A, B>(f: (a: A) => Option<B>, message: string): (self: Options<A>) => Options<B>;
<A, B>(self: Options<A>, f: (a: A) => Option<B>, message: string): Options<B>;
};Signature
declare const getHelp: <A>(self: Options<A>) => HelpDoc;getIdentifier
Signature
declare const getIdentifier: <A>(self: Options<A>) => Option<string>;Signature
declare const getUsage: <A>(self: Options<A>) => Usage;Signature
declare const isBool: <A>(self: Options<A>) => boolean;Signature
declare const map: {
<A, B>(f: (a: A) => B): (self: Options<A>) => Options<B>;
<A, B>(self: Options<A>, f: (a: A) => B): Options<B>;
};Signature
declare const mapEffect: {
<A, B>(f: (a: A) => Effect<B, ValidationError, any>): (self: Options<A>) => Options<B>;
<A, B>(self: Options<A>, f: (a: A) => Effect<B, ValidationError, any>): Options<B>;
};mapTryCatch
Signature
declare const mapTryCatch: {
<A, B>(f: (a: A) => B, onError: (e: unknown) => HelpDoc): (self: Options<A>) => Options<B>;
<A, B>(self: Options<A>, f: (a: A) => B, onError: (e: unknown) => HelpDoc): Options<B>;
};Signature
declare const optional: <A>(self: Options<A>) => Options<Option<A>>;Signature
declare const orElse: {
<A>(that: Options<A>): <B>(self: Options<B>) => Options<A | B>;
<A, B>(self: Options<A>, that: Options<B>): Options<A | B>;
};orElseEither
Signature
declare const orElseEither: {
<A>(that: Options<A>): <B>(self: Options<B>) => Options<Either<A, B>>;
<A, B>(self: Options<A>, that: Options<B>): Options<Either<A, B>>;
};Signature
declare const parse: {
(args: HashMap<string, readonly Array<string>>, config: CliConfig): <A>(self: Options<A>) => Effect<A, ValidationError, FileSystem>;
<A>(self: Options<A>, args: HashMap<string, readonly Array<string>>, config: CliConfig): Effect<A, ValidationError, FileSystem>;
}processCommandLine
Processes the provided command-line arguments, searching for the specified Options.
Returns an Option<ValidationError>, any leftover arguments, and the constructed value of type A. The possible error inside Option<ValidationError> would only be triggered if there is an error when parsing the command-line arguments. This is because ValidationErrors are also used internally to control the end of the command-line arguments (i.e. the command-line symbol --) corresponding to options.
Signature
declare const processCommandLine: {
(args: readonly Array<string>, config: CliConfig): <A>(self: Options<A>) => Effect<[Option<ValidationError>, Array<string>, A], ValidationError, any>;
<A>(self: Options<A>, args: readonly Array<string>, config: CliConfig): Effect<[Option<ValidationError>, Array<string>, A], ValidationError, any>;
}Indicates that the specified command-line option can be repeated 0 or more times.
NOTE: if the command-line option is not provided, and empty array will be returned as the value for said option.
Signature
declare const repeated: <A>(self: Options<A>) => Options<Array<A>>;Signature
declare const withAlias: {
(alias: string): <A>(self: Options<A>) => Options<A>;
<A>(self: Options<A>, alias: string): Options<A>;
};withDefault
Signature
declare const withDefault: {
<B>(fallback: B): <A>(self: Options<A>) => Options<B | A>;
<A, B>(self: Options<A>, fallback: B): Options<A | B>;
};withDescription
Signature
declare const withDescription: {
(description: string): <A>(self: Options<A>) => Options<A>;
<A>(self: Options<A>, description: string): Options<A>;
};withFallbackConfig
Signature
declare const withFallbackConfig: {
<B>(config: Config<B>): <A>(self: Options<A>) => Options<B | A>;
<A, B>(self: Options<A>, config: Config<B>): Options<A | B>;
};withFallbackPrompt
Signature
declare const withFallbackPrompt: {
<B>(prompt: Prompt<B>): <A>(self: Options<A>) => Options<B | A>;
<A, B>(self: Options<A>, prompt: Prompt<B>): Options<A | B>;
};withPseudoName
Signature
declare const withPseudoName: {
(pseudoName: string): <A>(self: Options<A>) => Options<A>;
<A>(self: Options<A>, pseudoName: string): Options<A>;
};withSchema
Signature
declare const withSchema: {
<A, I, B>(schema: any): (self: Options<A>) => Options<B>;
<A, I, B>(self: Options<A>, schema: any): Options<B>;
};Signature
declare const wizard: {
(config: CliConfig): <A>(self: Options<A>) => Effect<Array<string>, any, any>;
<A>(self: Options<A>, config: CliConfig): Effect<Array<string>, any, any>;
};Constructors
Signature
declare const all: <Arg extends Iterable<Options<any>> | Record<string, Options<any>>>(
arg: Arg,
) => All.Return<Arg>;Signature
declare const boolean: (name: string, options?: Options.BooleanOptionsConfig) => Options<boolean>;Constructs command-line Options that represent a choice between several inputs. The input will be mapped to it's associated value during parsing.
Signature
declare const choice: <A extends string, C extends ReadonlyArray<A>>(
name: string,
choices: C,
) => Options<C[number]>;Example
import * as Options from "@effect/cli/Options"
export const animal: Options.Options<"dog" | "cat"> = Options.choice("animal", ["dog", "cat"])choiceWithValue
Constructs command-line Options that represent a choice between several inputs. The input will be mapped to it's associated value during parsing.
Signature
declare const choiceWithValue: <C extends ReadonlyArray<[string, any]>>(
name: string,
choices: C,
) => Options<C[number][1]>;Example
import * as Options from "@effect/cli/Options"
import * as Data from "effect/Data"
export type Animal = Dog | Cat
export interface Dog {
readonly _tag: "Dog"
}
export const Dog = Data.tagged<Dog>("Dog")
export interface Cat {
readonly _tag: "Cat"
}
export const Cat = Data.tagged<Cat>("Cat")
export const animal: Options.Options<Animal> = Options.choiceWithValue("animal", [
["dog", Dog()],
["cat", Cat()],
])Signature
declare const date: (name: string) => Options<globalThis.Date>;Creates a parameter expecting path to a directory.
Signature
declare const directory: (name: string, config?: Options.PathOptionsConfig) => Options<string>;Creates a parameter expecting path to a file.
Signature
declare const file: (name: string, config?: Options.PathOptionsConfig) => Options<string>;fileContent
Creates a parameter expecting path to a file and reads its contents.
Signature
declare const fileContent: (name: string) => Options<readonly [path: string, content: Uint8Array]>;Creates a parameter expecting path to a file and parse its contents.
Signature
declare const fileParse: (
name: string,
format?: "json" | "yaml" | "ini" | "toml",
) => Options<unknown>;fileSchema
Creates a parameter expecting path to a file, parse its contents and validate it with a Schema.
Signature
declare const fileSchema: <I, A>(
name: string,
schema: Schema<A, I, FileSystem | Path | Terminal>,
format?: "json" | "yaml" | "ini" | "toml",
) => Options<A>;Creates a parameter expecting path to a file and reads its contents.
Signature
declare const fileText: (name: string) => Options<readonly [path: string, content: string]>;Signature
declare const float: (name: string) => Options<number>;Signature
declare const integer: (name: string) => Options<number>;keyValueMap
Signature
declare const keyValueMap: (option: string | Options<string>) => Options<HashMap<string, string>>;Signature
declare const none: Options<void>;Signature
declare const redacted: (name: string) => Options<Redacted>;Signature
declare const secret: (name: string) => Options<Secret>;Signature
declare const text: (name: string) => Options<string>;Models
Other
Refinements
Symbols
OptionsTypeId
Signature
declare const OptionsTypeId: unique symbol;OptionsTypeId type
Signature
type OptionsTypeId = typeof OptionsTypeId;
Returns
trueif the specifiedOptionsis a boolean flag,falseotherwise.