Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/lume/deps/cliffy.ts>Type

🔥 Static site generator for Deno 🦕
Very Popular
Go to Latest
namespace Type
Re-export
import { Type } from "https://deno.land/x/lume@v1.16.1/deps/cliffy.ts";
class Type
Re-export
Abstract
import { Type } from "https://deno.land/x/lume@v1.16.1/deps/cliffy.ts";

Base class for custom types.

Custom type example:

export class ColorType extends Type<string> {
  public parse({ label, name, value, type }: ArgumentValue): 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

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

abstract
parse(type: ArgumentValue): TValue
optional
values(cmd: Command, parent?: Command): ValuesHandlerResult

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