Skip to content

MiddlewareParams

Parameters received by a middleware function at runtime.

Middleware receives erased args/flags (since it's defined independently of commands) plus the accumulated context from prior middleware and a next function to continue the chain.

Signatures

ts
interface MiddlewareParams {}

Members

Properties

args

Fully resolved positional arguments (type-erased).

ts
args: Readonly<Record<string, unknown>>;

ctx

Context accumulated from previous middleware in the chain.

ts
ctx: Readonly<Record<string, unknown>>;

flags

Fully resolved flags (type-erased).

ts
flags: Readonly<Record<string, unknown>>;

meta

CLI program metadata (name, bin, version, command).

ts
meta: CommandMeta;

next

Continue to the next middleware or action handler.

Call with context additions that merge into ctx for downstream. Returns when the entire downstream chain completes — enabling wrap-around patterns (timing, try/catch, cleanup).

ts
next: { (additions: Record<string, unknown>): Promise<void>; };

out

Output channel.

ts
out: Out;

See Also

Released under the MIT License.