variable command

.header — what this session will send, and what the last request actually sent and got back.

Three questions that are really one, which is why they are one command. "What am I sending", "what did I send", and "what came back" are asked in the same breath, and a prompt that made you remember three names for them would be answering a different question than the one you have.

The shapes:

.header                        what all of this is — the shapes below, on one screen
.header list                   the headers saved for the next request
.header accept=application/json   save one — `.header accept: application/json` also works
.header add accept=…           the same, for hands that want a verb
.header accept                 what one is set to
.header delete accept [more…]  stop sending them — `del`, `remove` and `rm` too
.header clear                  stop sending any of them
.header sent                   what the last request actually sent
.header received               what came back on the last request
.header 2 sent                 the same, for an earlier request — `#3` names one by id
.header received #3            either order: which half and which request, in either sequence

.headers is the same command, with one difference: bare, the plural lists. The plural IS the block, so asking for it by itself means "show me them"; the singular reads as a question about the command, and answers with what it can do. Everything after the name behaves identically.

import { command as headerCommand } from './header.ts';

import type { ReplContext } from '../command.ts';

// Defined, not invoked: it writes to a live prompt.
function example(repl: ReplContext) {
  return headerCommand.main(repl, 'accept=application/json'); // saved for the next request
}

Type

Usage

import { command } from "lib/commands/repl/commands/header.ts";