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

CommandDescriptor overview

Added in v1.0.0


Table of contents


combinators

getBashCompletions

Signature

export declare const getBashCompletions: <A>(self: Command<A>, programName: string) => Effect<Array<string>>

Added in v1.0.0

getFishCompletions

Signature

export declare const getFishCompletions: <A>(self: Command<A>, programName: string) => Effect<Array<string>>

Added in v1.0.0

getHelp

Signature

export declare const getHelp: <A>(self: Command<A>, config: CliConfig) => HelpDoc

Added in v1.0.0

getNames

Signature

export declare const getNames: <A>(self: Command<A>) => HashSet<string>

Added in v1.0.0

getSubcommands

Signature

export declare const getSubcommands: <A>(self: Command<A>) => HashMap<string, Command<unknown>>

Added in v1.0.0

getUsage

Signature

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

Added in v1.0.0

getZshCompletions

Signature

export declare const getZshCompletions: <A>(self: Command<A>, programName: string) => Effect<Array<string>>

Added in v1.0.0

map

Signature

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

Added in v1.0.0

mapEffect

Signature

export declare const mapEffect: {
  <A, B>(f: (a: A) => Effect<B, ValidationError, FileSystem | Path | Terminal>): (self: Command<A>) => Command<B>
  <A, B>(self: Command<A>, f: (a: A) => Effect<B, ValidationError, FileSystem | Path | Terminal>): Command<B>
}

Added in v1.0.0

parse

Signature

export declare const parse: {
  (
    args: ReadonlyArray<string>,
    config: CliConfig
  ): <A>(self: Command<A>) => Effect<CommandDirective<A>, ValidationError, FileSystem | Path | Terminal>
  <A>(
    self: Command<A>,
    args: ReadonlyArray<string>,
    config: CliConfig
  ): Effect<CommandDirective<A>, ValidationError, FileSystem | Path | Terminal>
}

Added in v1.0.0

withDescription

Signature

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

Added in v1.0.0

withSubcommands

Signature

export declare const withSubcommands: {
  <
    const Subcommands extends readonly [
      readonly [id: unknown, command: Command<any>],
      ...Array<readonly [id: unknown, command: Command<any>]>
    ]
  >(
    subcommands: [...Subcommands]
  ): <A>(
    self: Command<A>
  ) => Command<Command.ComputeParsedType<A & Readonly<{ subcommand: Option<Command.Subcommands<Subcommands>> }>>>
  <
    A,
    const Subcommands extends readonly [
      readonly [id: unknown, command: Command<any>],
      ...Array<readonly [id: unknown, command: Command<any>]>
    ]
  >(
    self: Command<A>,
    subcommands: [...Subcommands]
  ): Command<Command.ComputeParsedType<A & Readonly<{ subcommand: Option<Command.Subcommands<Subcommands>> }>>>
}

Added in v1.0.0

wizard

Signature

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

Added in v1.0.0

constructors

make

Signature

export declare const make: <Name extends string, OptionsType = void, ArgsType = void>(
  name: Name,
  options?: Options<OptionsType>,
  args?: Args<ArgsType>
) => Command<{ readonly name: Name; readonly options: OptionsType; readonly args: ArgsType }>

Added in v1.0.0

prompt

Signature

export declare const prompt: <Name extends string, A>(
  name: Name,
  prompt: Prompt<A>
) => Command<{ readonly name: Name; readonly value: A }>

Added in v1.0.0

models

Command (interface)

A Command represents a command in a command-line application.

Every command-line application will have at least one command: the application itself. Other command-line applications may support multiple commands.

Signature

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

Added in v1.0.0

symbols

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

utils

Command (namespace)

Added in v1.0.0

Variance (interface)

Signature

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

Added in v1.0.0

ComputeParsedType (type alias)

Signature

export type ComputeParsedType<A> = { [K in keyof A]: A[K] } extends infer X ? X : never

Added in v1.0.0

GetParsedType (type alias)

Signature

export type GetParsedType<C> = C extends Command<infer P> ? P : never

Added in v1.0.0

ParsedStandardCommand (type alias)

Signature

export type ParsedStandardCommand<Name extends string, OptionsType, ArgsType> = Command.ComputeParsedType<{
  readonly name: Name
  readonly options: OptionsType
  readonly args: ArgsType
}>

Added in v1.0.0

ParsedUserInputCommand (type alias)

Signature

export type ParsedUserInputCommand<Name extends string, ValueType> = Command.ComputeParsedType<{
  readonly name: Name
  readonly value: ValueType
}>

Added in v1.0.0

Subcommands (type alias)

Signature

export type Subcommands<A extends NonEmptyReadonlyArray<readonly [id: unknown, command: Command<any>]>> = {
  [I in keyof A]: A[I] extends readonly [infer Id, Command<infer Value>] ? readonly [id: Id, value: Value] : never
}[number]

Added in v1.0.0