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

x/cliffy/prompt/prompt.ts>GlobalPromptMiddleware

Command line framework for deno 🦕 Including Commandline-Interfaces, Prompts, CLI-Table, Arguments Parser and more...
Extremely Popular
Go to Latest
type alias GlobalPromptMiddleware
import { type GlobalPromptMiddleware } from "https://deno.land/x/cliffy@v1.0.0-rc.1/prompt/prompt.ts";

Prompt middleware function.

import { prompt } from "./prompt.ts";
import { Input } from "./input.ts";

const result = await prompt([{
  name: "name",
  message: "Project name",
  type: Input,
}, {
  name: "path",
  message: "Project path",
  type: Input,
}], {
  async before(promptName, { name }, next) {
    // do something before {promptName} excution.
    await next();
    // all prompts executed.
  },
  async after(promptName, { name }, next) {
    // do something after {promptName} excution.
    await next();
    // all prompts executed.
  }
});
definition: (
name: keyof TResult,
result: TResult,
next: Next<Exclude<keyof TResult, symbol>>,
) => void | Promise<void>