Skip to main content Link Search Menu Expand Document (external link)

Args overview

Added in v1.0.0


Table of contents


combinators

atLeast

Signature

export declare const atLeast: {
  (times: 0): <A>(self: Args<A>) => Args<readonly A[]>
  (times: number): <A>(self: Args<A>) => Args<readonly [A, ...A[]]>
  <A>(self: Args<A>, times: 0): Args<readonly A[]>
  <A>(self: Args<A>, times: number): Args<readonly [A, ...A[]]>
}

Added in v1.0.0

atMost

Signature

export declare const atMost: {
  (times: number): <A>(self: Args<A>) => Args<readonly A[]>
  <A>(self: Args<A>, times: number): Args<readonly A[]>
}

Added in v1.0.0

between

Signature

export declare const between: {
  (min: 0, max: number): <A>(self: Args<A>) => Args<readonly A[]>
  (min: number, max: number): <A>(self: Args<A>) => Args<readonly [A, ...A[]]>
  <A>(self: Args<A>, min: 0, max: number): Args<readonly A[]>
  <A>(self: Args<A>, min: number, max: number): Args<readonly [A, ...A[]]>
}

Added in v1.0.0

getHelp

Signature

export declare const getHelp: <A>(self: Args<A>) => HelpDoc

Added in v1.0.0

getIdentifier

Signature

export declare const getIdentifier: <A>(self: Args<A>) => Option<string>

Added in v1.0.0

getMaxSize

Signature

export declare const getMaxSize: <A>(self: Args<A>) => number

Added in v1.0.0

getMinSize

Signature

export declare const getMinSize: <A>(self: Args<A>) => number

Added in v1.0.0

getUsage

Signature

export declare const getUsage: <A>(self: Args<A>) => Usage

Added in v1.0.0

optional

Signature

export declare const optional: <A>(self: Args<A>) => Args<Option<A>>

Added in v1.0.0

repeated

Signature

export declare const repeated: <A>(self: Args<A>) => Args<readonly A[]>

Added in v1.0.0

validate

Signature

export declare const validate: {
  (
    args: ReadonlyArray<string>,
    config: CliConfig
  ): <A>(self: Args<A>) => Effect<FileSystem, ValidationError, [readonly string[], A]>
  <A>(
    self: Args<A>,
    args: ReadonlyArray<string>,
    config: CliConfig
  ): Effect<FileSystem, ValidationError, [readonly string[], A]>
}

Added in v1.0.0

withDefault

Signature

export declare const withDefault: {
  <const B>(fallback: B): <A>(self: Args<A>) => Args<B | A>
  <A, const B>(self: Args<A>, fallback: B): Args<A | B>
}

Added in v1.0.0

withDescription

Signature

export declare const withDescription: {
  (description: string): <A>(self: Args<A>) => Args<A>
  <A>(self: Args<A>, description: string): Args<A>
}

Added in v1.0.0

withFallbackConfig

Signature

export declare const withFallbackConfig: {
  <B>(config: Config<B>): <A>(self: Args<A>) => Args<B | A>
  <A, B>(self: Args<A>, config: Config<B>): Args<A | B>
}

Added in v1.0.0

wizard

Signature

export declare const wizard: {
  (
    config: CliConfig
  ): <A>(self: Args<A>) => Effect<FileSystem | Terminal, ValidationError | QuitException, ReadonlyArray<string>>
  <A>(
    self: Args<A>,
    config: CliConfig
  ): Effect<FileSystem | Terminal, ValidationError | QuitException, ReadonlyArray<string>>
}

Added in v1.0.0

constructors

all

Signature

export declare const all: <const Arg extends Iterable<Args<any>> | Record<string, Args<any>>>(
  arg: Arg
) => All.Return<Arg>

Added in v1.0.0

boolean

Creates a boolean argument.

Can optionally provide a custom argument name (defaults to "boolean").

Signature

export declare const boolean: (options?: Args.BaseArgsConfig) => Args<boolean>

Added in v1.0.0

choice

Creates a choice argument.

Can optionally provide a custom argument name (defaults to "choice").

Signature

export declare const choice: <A>(
  choices: readonly [[string, A], ...[string, A][]],
  config?: Args.BaseArgsConfig
) => Args<A>

Added in v1.0.0

date

Creates a date argument.

Can optionally provide a custom argument name (defaults to "date").

Signature

export declare const date: (config?: Args.BaseArgsConfig) => Args<globalThis.Date>

Added in v1.0.0

directory

Creates a directory argument.

Can optionally provide a custom argument name (defaults to "directory").

Signature

export declare const directory: (config?: Args.PathArgsConfig) => Args<string>

Added in v1.0.0

file

Creates a file argument.

Can optionally provide a custom argument name (defaults to "file").

Signature

export declare const file: (config?: Args.PathArgsConfig) => Args<string>

Added in v1.0.0

float

Creates a floating point number argument.

Can optionally provide a custom argument name (defaults to "float").

Signature

export declare const float: (config?: Args.BaseArgsConfig) => Args<number>

Added in v1.0.0

integer

Creates an integer argument.

Can optionally provide a custom argument name (defaults to "integer").

Signature

export declare const integer: (config?: Args.BaseArgsConfig) => Args<number>

Added in v1.0.0

none

Creates an empty argument.

Signature

export declare const none: Args<void>

Added in v1.0.0

path

Creates a path argument.

Can optionally provide a custom argument name (defaults to "path").

Signature

export declare const path: (config?: Args.PathArgsConfig) => Args<string>

Added in v1.0.0

secret

Creates a text argument.

Can optionally provide a custom argument name (defaults to "secret").

Signature

export declare const secret: (config?: Args.BaseArgsConfig) => Args<Secret>

Added in v1.0.0

text

Creates a text argument.

Can optionally provide a custom argument name (defaults to "text").

Signature

export declare const text: (config?: Args.BaseArgsConfig) => Args<string>

Added in v1.0.0

mapping

map

Signature

export declare const map: {
  <A, B>(f: (a: A) => B): (self: Args<A>) => Args<B>
  <A, B>(self: Args<A>, f: (a: A) => B): Args<B>
}

Added in v1.0.0

mapOrFail

Signature

export declare const mapOrFail: {
  <A, B>(f: (a: A) => Either<HelpDoc, B>): (self: Args<A>) => Args<B>
  <A, B>(self: Args<A>, f: (a: A) => Either<HelpDoc, B>): Args<B>
}

Added in v1.0.0

mapTryCatch

Signature

export declare const mapTryCatch: {
  <A, B>(f: (a: A) => B, onError: (e: unknown) => HelpDoc): (self: Args<A>) => Args<B>
  <A, B>(self: Args<A>, f: (a: A) => B, onError: (e: unknown) => HelpDoc): Args<B>
}

Added in v1.0.0

models

Args (interface)

Represents arguments that can be passed to a command-line application.

Signature

export interface Args<A> extends Args.Variance<A>, Pipeable {}

Added in v1.0.0

refinements

isArgs

Signature

export declare const isArgs: (u: unknown) => u is Args<unknown>

Added in v1.0.0

symbols

ArgsTypeId

Signature

export declare const ArgsTypeId: typeof ArgsTypeId

Added in v1.0.0

ArgsTypeId (type alias)

Signature

export type ArgsTypeId = typeof ArgsTypeId

Added in v1.0.0

utils

All (namespace)

Added in v1.0.0

ArgsAny (type alias)

Signature

export type ArgsAny = Args<any>

Added in v1.0.0

Return (type alias)

Signature

export type Return<Arg extends Iterable<ArgsAny> | Record<string, ArgsAny>> = [Arg] extends [ReadonlyArray<ArgsAny>]
  ? ReturnTuple<Arg>
  : [Arg] extends [Iterable<ArgsAny>]
    ? ReturnIterable<Arg>
    : [Arg] extends [Record<string, ArgsAny>]
      ? ReturnObject<Arg>
      : never

Added in v1.0.0

ReturnIterable (type alias)

Signature

export type ReturnIterable<T extends Iterable<ArgsAny>> = [T] extends [Iterable<Args.Variance<infer A>>]
  ? Args<Array<A>>
  : never

Added in v1.0.0

ReturnObject (type alias)

Signature

export type ReturnObject<T> = [T] extends [{ [K: string]: ArgsAny }]
  ? Args<{
      -readonly [K in keyof T]: [T[K]] extends [Args.Variance<infer _A>] ? _A : never
    }>
  : never

Added in v1.0.0

ReturnTuple (type alias)

Signature

export type ReturnTuple<T extends ReadonlyArray<unknown>> = Args<
  T[number] extends never
    ? []
    : {
        -readonly [K in keyof T]: [T[K]] extends [Args.Variance<infer _A>] ? _A : never
      }
> extends infer X
  ? X
  : never

Added in v1.0.0

Args (namespace)

Added in v1.0.0

BaseArgsConfig (interface)

Signature

export interface BaseArgsConfig {
  readonly name?: string
}

Added in v1.0.0

PathArgsConfig (interface)

Signature

export interface PathArgsConfig extends BaseArgsConfig {
  readonly exists?: Primitive.PathExists
}

Added in v1.0.0

Variance (interface)

Signature

export interface Variance<A> {
  readonly [ArgsTypeId]: {
    readonly _A: (_: never) => A
  }
}

Added in v1.0.0