Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict';
const { AutoComplete } = require('enquirer');
/**
* This examples shows how to "play" an array of keypresses.
*/
const timeout = (fn, ms = 0) => {
return new Promise((resolve, reject) => {
setTimeout(() => fn().then(resolve).catch(reject), ms);
});
};
const prompt = new AutoComplete({
name: 'flavor',
message: 'Pick your favorite flavor',
choices: [
'almond',
'apple',
'banana',
'cherry',
'chocolate',
'cinnamon',
'coconut',
'cotton candy',
'grape',
'nougat',
'orange',
'pear',
'pineapple',
const getSuggestion = async subcommands => {
const prompt = new AutoComplete({
name: 'Subcommand',
message: 'Select a command',
limit: 100,
choices: subcommands.map(cmd => cmd.key),
})
const answer = await prompt.run()
return subcommands.find(cmd => cmd.key == answer)
}
function getStepPrompt(step) {
switch (step.type) {
case "option":
return new AutoComplete({
name: "step",
message: step.message,
choices: step.options.map(option => option.description)
})
.run()
.then(choice => {
const result = step.options.find(
option => option.description === choice
);
return result.value;
});
case "text":
return new Input({
message: step.message,
initial: step.initial
export default async (initialColor = "#2550b0") => {
const prompt = new AutoComplete({
message: `Pick a color`,
choices: [
{ message: chalk.hex("#2550b0")("█ ") + "Cerulean blue", value: "#2550b0" },
{ message: chalk.hex("#00ffff")("█ ") + "Aqua", value: "#00ffff" },
{ message: chalk.hex("#000000")("█ ") + "Black", value: "#000000" },
{ message: chalk.hex("#0000ff")("█ ") + "Blue", value: "#0000ff" },
{ message: chalk.hex("#ff00ff")("█ ") + "Fuchsia", value: "#ff00ff" },
{ message: chalk.hex("#808080")("█ ") + "Gray", value: "#808080" },
{ message: chalk.hex("#008000")("█ ") + "Green", value: "#008000" },
{ message: chalk.hex("#00ff00")("█ ") + "Lime", value: "#00ff00" },
{ message: chalk.hex("#800000")("█ ") + "Maroon", value: "#800000" },
{ message: chalk.hex("#000080")("█ ") + "Navy", value: "#000080" },
{ message: chalk.hex("#808000")("█ ") + "Olive", value: "#808000" },
{ message: chalk.hex("#800080")("█ ") + "Purple", value: "#800080" },
{ message: chalk.hex("#ff0000")("█ ") + "Red", value: "#ff0000" },
{ message: chalk.hex("#c0c0c0")("█ ") + "Silver", value: "#c0c0c0" },
const name = `${method} ${endpointInfo.label}`;
const message = `${name} ${methodText}`;
choices.push({
message: message,
name: name,
value: `${endpoint}|${method}`
});
});
});
choices.sort((choiceA, choiceB) => {
return choiceA.message < choiceB.message ? -1 : 1;
});
const prompt = new AutoComplete({
message: "Which endpoint would you like to use? (Type to search)",
format: () => {
if (prompt.focused) {
return prompt.style(prompt.focused.name);
}
return prompt.style("No matches");
},
result: value => {
if (!prompt.focused) return value;
return prompt.focused.value;
},
choices: choices
});
const selectedEndpoint: string = await prompt.run();
'use strict';
const { AutoComplete } = require('enquirer');
const prompt = new AutoComplete({
name: 'flavor',
message: 'Pick your favorite flavor',
limit: 10,
choices: [
'Almond',
'Apple',
'Banana',
'Blackberry',
'Blueberry',
'Cherry',
'Chocolate',
'Cinnamon',
'Coconut',
'Cranberry',
'Grape',
'Nougat',
'use strict';
const path = require('path');
const Store = require('data-store');
const store = new Store({ path: path.join(__dirname, 'recordings.json') });
const { AutoComplete } = require('enquirer');
const prompt = new AutoComplete({
name: 'flavor',
message: 'Pick your favorite flavor',
choices: [
'almond',
'apple',
'banana',
'cherry',
'chocolate',
'cinnamon',
'coconut',
'cotton candy',
'grape',
'nougat',
'orange',
'pear',
'pineapple',
'use strict';
const path = require('path');
const Store = require('data-store');
const store = new Store({ path: path.join(__dirname, 'recordings.json') });
const { AutoComplete } = require('enquirer');
const timeout = (fn, ms = 0) => {
return new Promise((resolve, reject) => {
setTimeout(() => fn().then(resolve).catch(reject), ms);
});
};
const prompt = new AutoComplete({
name: 'flavor',
message: 'Pick your favorite flavor',
choices: [
'almond',
'apple',
'banana',
'cherry',
'chocolate',
'cinnamon',
'coconut',
'cotton candy',
'grape',
'nougat',
'orange',
'pear',
'pineapple',