Module

x/cliffy/mod.ts>Type

Command line framework for deno 🦕 Including Commandline-Interfaces, Prompts, CLI-Table, Arguments Parser and more...
Extremely Popular
Go to Latest
class Type
Abstract
import { Type } from "https://dotland.deno.dev/x/cliffy@v0.19.0/mod.ts";

Base class for custom types.

Custom type example:

export class ColorType extends Type<string> {
  public parse({ label, name, value, type }: ITypeInfo): string {
    if (["red", "blue"].includes(value)) {
      trow new Error(
        `${label} "${name}" must be of type "${type}", but got "${value}".` +
        "Valid colors are: red, blue"
      );
    }
    return value;
  }

  public complete(): string[] {
    return ["red", "blue"];
  }
}

Methods

optional
complete(cmd: Command<any, any, any, any, any>, parent?: Command<any, any, any, any, any>): CompleteHandlerResult

Returns shell completion values. If no complete method is provided, values from the values method are used.

abstract
parse(type: ITypeInfo): T
optional
values(cmd: Command<any, any, any, any, any>, parent?: Command<any, any, any, any, any>): ValuesHandlerResult

Returns values displayed in help text. If no complete method is provided, these values are also used for shell completions.

import Type
import { Type } from "https://dotland.deno.dev/x/cliffy@v0.19.0/mod.ts";