Skip to main content
Module

x/spektr/spektr.ts>CLI

Elegant CLI framework.
Latest
class CLI
import { CLI } from "https://deno.land/x/spektr@0.0.5/spektr.ts";

Skeptr CLI app class.

Constructors

new
CLI(opts?: { name?: string; prefix?: string; plugins?: Plugin[]; helpFn?: (cmd: Command) => string; } & ParseArgsConfig)

Properties

commands: Command[]
optional
helpFn: (cmd: Command) => string
optional
name: string

CLI name

optional
parent: CLI
plugins: Plugin[]
optional
prefix: string

CLI Prefix, for example auth

programs: CLI[]

Methods

command<T extends readonly Option[] = readonly Option[]>(
name: string,
action: Action<T>,
params?: Params<T>,
): Command
command<T extends readonly Option[] = readonly Option[]>(name: string, action: Action<T>): Command
command<T extends readonly Option[] = readonly Option[]>(action: Action<T>, params?: Params<T>): Command
createVersionMessage(version?, misc?)
handle(args: string[]): void

Handle commands with the given arguments. For Deno use Deno.args, for Node.js and Bun use process.argv

Add a help command when invoking --help

program(prefix: string, program?)

Create a program, aka sub-command. It will handle all commands starting with a specified prefix

version(version?: string, misc?)

Display a version when invoking --version