One command the prompt answers to: the sentence .help prints beside it, and what typing it
does.
main takes a ReplContext and its argument rather than reading this, which is what
makes a command a plain function: tree.main(repl, '-L 1 lib') runs it, and a test can hand it
a context instead of standing up a terminal.
import type { ReplCommand } from './command.ts'; const pwd: ReplCommand = { description: 'Print the directory paths are resolved against', main(repl) { repl.log(repl.cwd); }, }; pwd.description.length > 0; // true
description: string
What .help says about it. One line: the list is read at a glance or not at all.
aliases: readonly string[]
Other names for the same command. .help folds them onto its line as [aliases .c, .n].
main(repl: ReplContext,argument: string): void | Promise<void>
What typing it does. repl first because nearly every command needs it and many ignore the
argument entirely — which they can then simply not declare.
argument is everything after the name, untrimmed.
May be async. define draws the prompt when it finishes and catches what it throws,
so a command's job ends when it has said its piece.