Skip to main content
Module

x/cliffy/prompt/mod.ts>inject

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

Inject prompt values. Can be used for unit tests.

In the following example, the prompt() method only asks for the color. The values for name' and age' are selected from the values injected by the `inject()' method and the prompts are skipped.

import { inject, prompt } from "./prompt.ts";
import { Input } from "./input.ts";
import { Number } from "./number.ts";
import { Confirm } from "./confirm.ts";
import { Checkbox } from "./checkbox.ts";

inject({
  name: "Joe",
  age: 34,
});

const result = await prompt([{
  name: "name",
  message: "What's your name?",
  type: Input,
}, {
  name: "age",
  message: "How old are you?",
  type: Confirm,
}, {
  name: "color",
  message: "Whats your favorit color?",
  type: Checkbox,
  options: ["red", "green", "blue"],
}]);

Parameters

values: Record<string, any>

Input values object.