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

Command overview

Added in v1.0.0


Table of contents


accessors

getBashCompletions

Signature

export declare const getBashCompletions: <Name extends string, R, E, A>(
  self: Command<Name, R, E, A>,
  programName: string
) => Effect<never, never, ReadonlyArray<string>>

Added in v1.0.0

getFishCompletions

Signature

export declare const getFishCompletions: <Name extends string, R, E, A>(
  self: Command<Name, R, E, A>,
  programName: string
) => Effect<never, never, ReadonlyArray<string>>

Added in v1.0.0

getHelp

Signature

export declare const getHelp: <Name extends string, R, E, A>(self: Command<Name, R, E, A>, config: CliConfig) => HelpDoc

Added in v1.0.0

getNames

Signature

export declare const getNames: <Name extends string, R, E, A>(self: Command<Name, R, E, A>) => HashSet<string>

Added in v1.0.0

getSubcommands

Signature

export declare const getSubcommands: <Name extends string, R, E, A>(
  self: Command<Name, R, E, A>
) => HashMap<string, Descriptor.Command<unknown>>

Added in v1.0.0

getUsage

Signature

export declare const getUsage: <Name extends string, R, E, A>(self: Command<Name, R, E, A>) => Usage

Added in v1.0.0

getZshCompletions

Signature

export declare const getZshCompletions: <Name extends string, R, E, A>(
  self: Command<Name, R, E, A>,
  programName: string
) => Effect<never, never, ReadonlyArray<string>>

Added in v1.0.0

wizard

Signature

export declare const wizard: {
  (
    prefix: ReadonlyArray<string>,
    config: CliConfig
  ): <Name extends string, R, E, A>(
    self: Command<Name, R, E, A>
  ) => Effect<Terminal | FileSystem, QuitException | ValidationError, ReadonlyArray<string>>
  <Name extends string, R, E, A>(
    self: Command<Name, R, E, A>,
    prefix: ReadonlyArray<string>,
    config: CliConfig
  ): Effect<Terminal | FileSystem, QuitException | ValidationError, ReadonlyArray<string>>
}

Added in v1.0.0

combinators

provide

Signature

export declare const provide: {
  <A, LR, LE, LA>(
    layer: Layer<LR, LE, LA> | ((_: A) => Layer<LR, LE, LA>)
  ): <Name extends string, R, E>(self: Command<Name, R, E, A>) => Command<Name, LR | Exclude<R, LA>, LE | E, A>
  <Name extends string, R, E, A, LR, LE, LA>(
    self: Command<Name, R, E, A>,
    layer: Layer<LR, LE, LA> | ((_: A) => Layer<LR, LE, LA>)
  ): Command<Name, LR | Exclude<R, LA>, E | LE, A>
}

Added in v1.0.0

provideEffect

Signature

export declare const provideEffect: {
  <I, S, A, R2, E2>(
    tag: Tag<I, S>,
    effect: Effect<R2, E2, S> | ((_: A) => Effect<R2, E2, S>)
  ): <Name extends string, R, E>(self: Command<Name, R, E, A>) => Command<Name, R2 | Exclude<R, I>, E2 | E, A>
  <Name extends string, R, E, A, I, S, R2, E2>(
    self: Command<Name, R, E, A>,
    tag: Tag<I, S>,
    effect: Effect<R2, E2, S> | ((_: A) => Effect<R2, E2, S>)
  ): Command<Name, R2 | Exclude<R, I>, E | E2, A>
}

Added in v1.0.0

provideEffectDiscard

Signature

export declare const provideEffectDiscard: {
  <A, R2, E2, _>(
    effect: Effect<R2, E2, _> | ((_: A) => Effect<R2, E2, _>)
  ): <Name extends string, R, E>(self: Command<Name, R, E, A>) => Command<Name, R2 | R, E2 | E, A>
  <Name extends string, R, E, A, R2, E2, _>(
    self: Command<Name, R, E, A>,
    effect: Effect<R2, E2, _> | ((_: A) => Effect<R2, E2, _>)
  ): Command<Name, R | R2, E | E2, A>
}

Added in v1.0.0

provideSync

Signature

export declare const provideSync: {
  <I, S, A>(
    tag: Tag<I, S>,
    service: S | ((_: A) => S)
  ): <Name extends string, R, E>(self: Command<Name, R, E, A>) => Command<Name, Exclude<R, I>, E, A>
  <Name extends string, R, E, A, I, S>(
    self: Command<Name, R, E, A>,
    tag: Tag<I, S>,
    service: S | ((_: A) => S)
  ): Command<Name, Exclude<R, I>, E, A>
}

Added in v1.0.0

transformHandler

Signature

export declare const transformHandler: {
  <R, E, A, R2, E2>(
    f: (effect: Effect<R, E, void>, config: A) => Effect<R2, E2, void>
  ): <Name extends string>(self: Command<Name, R, E, A>) => Command<Name, R | R2, E | E2, A>
  <Name extends string, R, E, A, R2, E2>(
    self: Command<Name, R, E, A>,
    f: (effect: Effect<R, E, void>, config: A) => Effect<R2, E2, void>
  ): Command<Name, R | R2, E | E2, A>
}

Added in v1.0.0

withDescription

Signature

export declare const withDescription: {
  (help: string | HelpDoc): <Name extends string, R, E, A>(self: Command<Name, R, E, A>) => Command<Name, R, E, A>
  <Name extends string, R, E, A>(self: Command<Name, R, E, A>, help: string | HelpDoc): Command<Name, R, E, A>
}

Added in v1.0.0

withHandler

Signature

export declare const withHandler: {
  <A, R, E>(
    handler: (_: A) => Effect<R, E, void>
  ): <Name extends string, XR, XE>(self: Command<Name, XR, XE, A>) => Command<Name, R, E, A>
  <Name extends string, XR, XE, A, R, E>(
    self: Command<Name, XR, XE, A>,
    handler: (_: A) => Effect<R, E, void>
  ): Command<Name, R, E, A>
}

Added in v1.0.0

withSubcommands

Signature

export declare const withSubcommands: {
  <Subcommand extends readonly [Command<any, any, any, any>, ...Command<any, any, any, any>[]]>(
    subcommands: Subcommand
  ): <Name extends string, R, E, A>(
    self: Command<Name, R, E, A>
  ) => Command<
    Name,
    R | Exclude<Effect.Context<ReturnType<Subcommand[number]["handler"]>>, Command.Context<Name>>,
    E | Effect.Error<ReturnType<Subcommand[number]["handler"]>>,
    Descriptor.Command.ComputeParsedType<
      A & Readonly<{ subcommand: Option<Descriptor.Command.GetParsedType<Subcommand[number]["descriptor"]>> }>
    >
  >
  <
    Name extends string,
    R,
    E,
    A,
    Subcommand extends readonly [Command<any, any, any, any>, ...Command<any, any, any, any>[]]
  >(
    self: Command<Name, R, E, A>,
    subcommands: Subcommand
  ): Command<
    Name,
    R | Exclude<Effect.Context<ReturnType<Subcommand[number]["handler"]>>, Command.Context<Name>>,
    E | Effect.Error<ReturnType<Subcommand[number]["handler"]>>,
    Descriptor.Command.ComputeParsedType<
      A & Readonly<{ subcommand: Option<Descriptor.Command.GetParsedType<Subcommand[number]["descriptor"]>> }>
    >
  >
}

Added in v1.0.0

constructors

fromDescriptor

Signature

export declare const fromDescriptor: {
  (): <A extends { readonly name: string }>(command: Descriptor.Command<A>) => Command<A["name"], never, never, A>
  <A extends { readonly name: string }, R, E>(
    handler: (_: A) => Effect<R, E, void>
  ): (command: Descriptor.Command<A>) => Command<A["name"], R, E, A>
  <A extends { readonly name: string }>(descriptor: Descriptor.Command<A>): Command<A["name"], never, never, A>
  <A extends { readonly name: string }, R, E>(
    descriptor: Descriptor.Command<A>,
    handler: (_: A) => Effect<R, E, void>
  ): Command<A["name"], R, E, A>
}

Added in v1.0.0

make

Signature

export declare const make: {
  <Name extends string>(name: Name): Command<Name, never, never, {}>
  <Name extends string, const Config extends Command.Config>(
    name: Name,
    config: Config
  ): Command<
    Name,
    never,
    never,
    Types.Simplify<Types.Simplify<{ readonly [Key in keyof Config]: Command.ParseConfigValue<Config[Key]> }>>
  >
  <Name extends string, const Config extends Command.Config, R, E>(
    name: Name,
    config: Config,
    handler: (
      _: Types.Simplify<Types.Simplify<{ readonly [Key in keyof Config]: Command.ParseConfigValue<Config[Key]> }>>
    ) => Effect<R, E, void>
  ): Command<
    Name,
    R,
    E,
    Types.Simplify<Types.Simplify<{ readonly [Key in keyof Config]: Command.ParseConfigValue<Config[Key]> }>>
  >
}

Added in v1.0.0

prompt

Signature

export declare const prompt: <Name extends string, A, R, E>(
  name: Name,
  prompt: Prompt<A>,
  handler: (_: A) => Effect<R, E, void>
) => Command<string, R, E, A>

Added in v1.0.0

conversions

run

Signature

export declare const run: {
  (config: {
    readonly name: string
    readonly version: string
    readonly summary?: Span | undefined
    readonly footer?: HelpDoc | undefined
  }): <Name extends string, R, E, A>(
    self: Command<Name, R, E, A>
  ) => (args: ReadonlyArray<string>) => Effect<R | CliApp.Environment, ValidationError | E, void>
  <Name extends string, R, E, A>(
    self: Command<Name, R, E, A>,
    config: {
      readonly name: string
      readonly version: string
      readonly summary?: Span | undefined
      readonly footer?: HelpDoc | undefined
    }
  ): (args: ReadonlyArray<string>) => Effect<R | CliApp.Environment, ValidationError | E, void>
}

Added in v1.0.0

models

Command (interface)

Signature

export interface Command<Name extends string, R, E, A> extends Pipeable, Effect<Command.Context<Name>, never, A> {
  readonly [TypeId]: TypeId
  readonly descriptor: Descriptor.Command<A>
  readonly handler: (_: A) => Effect<R, E, void>
  readonly tag: Tag<Command.Context<Name>, A>
  readonly transform: Command.Transform<R, E, A>
}

Added in v1.0.0

Command (namespace)

Added in v1.0.0

Config (interface)

Signature

export interface Config {
  readonly [key: string]: Args<any> | Options<any> | ReadonlyArray<Args<any> | Options<any> | Config> | Config
}

Added in v1.0.0

Context (interface)

Signature

export interface Context<Name extends string> {
  readonly _: unique symbol
  readonly name: Name
}

Added in v1.0.0

ParsedConfig (interface)

Signature

export interface ParsedConfig {
  readonly args: ReadonlyArray<Args<any>>
  readonly options: ReadonlyArray<Options<any>>
  readonly tree: ParsedConfigTree
}

Added in v1.0.0

ParseConfig (type alias)

Signature

export type ParseConfig<A extends Config> = Types.Simplify<{ readonly [Key in keyof A]: ParseConfigValue<A[Key]> }>

Added in v1.0.0

Transform (type alias)

Signature

export type Transform<R, E, A> = (effect: Effect<any, any, void>, config: A) => Effect<R, E, void>

Added in v1.0.0

type ids

TypeId

Signature

export declare const TypeId: typeof TypeId

Added in v1.0.0

TypeId (type alias)

Signature

export type TypeId = typeof TypeId

Added in v1.0.0