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<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<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<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<string[], any, any>
  <Name extends string, R, E, A>(
    self: Command<Name, R, E, A>,
    prefix: ReadonlyArray<string>,
    config: CliConfig
  ): Effect<string[], any, any>
}

Added in v1.0.0

combinators

provide

Signature

export declare const provide: {
  <A, LR, LE, LA>(
    layer: any
  ): <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: any
  ): 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: any
  ): <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: any
  ): Command<Name, R2 | Exclude<R, I>, E | E2, A>
}

Added in v1.0.0

provideEffectDiscard

Signature

export declare const provideEffectDiscard: {
  <A, R2, E2, _>(
    effect: any
  ): <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: any): 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<void, E, R>, config: A) => Effect<void, E2, R2>
  ): <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<void, E, R>, config: A) => Effect<void, E2, R2>
  ): 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<void, E, R>
  ): <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<void, E, R>
  ): 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,
    any,
    any,
    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,
    any,
    any,
    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<void, E, R>
  ): (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<void, E, R>
  ): 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 A]: Command.ParseConfigValue<A[Key]> }>>
  >
  <Name extends string, const Config extends Command.Config, R, E>(
    name: Name,
    config: Config,
    handler: (
      _: Types.Simplify<Types.Simplify<{ readonly [Key in keyof A]: Command.ParseConfigValue<A[Key]> }>>
    ) => Effect<void, E, R>
  ): Command<
    Name,
    R,
    E,
    Types.Simplify<Types.Simplify<{ readonly [Key in keyof A]: Command.ParseConfigValue<A[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<void, E, R>
) => Command<string, R, E, A>

Added in v1.0.0

conversions

run

Signature

export declare const run: {
  (
    config: Omit<CliApp.ConstructorArgs<never>, "command">
  ): <Name extends string, R, E, A>(
    self: Command<Name, R, E, A>
  ) => (args: ReadonlyArray<string>) => Effect<void, ValidationError | E, any>
  <Name extends string, R, E, A>(
    self: Command<Name, R, E, A>,
    config: Omit<CliApp.ConstructorArgs<never>, "command">
  ): (args: ReadonlyArray<string>) => Effect<void, ValidationError | E, any>
}

Added in v1.0.0

models

Command (interface)

Signature

export interface Command<Name extends string, R, E, A> extends Pipeable, Effect<A, never, Command.Context<Name>> {
  readonly [TypeId]: TypeId
  readonly descriptor: Descriptor.Command<A>
  readonly handler: (_: A) => Effect<void, E, R>
  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<void, any, any>, config: A) => Effect<void, E, R>

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