Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
@clack/prompts
Advanced tools
@clack/prompts is an npm package designed to facilitate the creation of interactive command-line prompts. It provides a variety of prompt types to gather user input in a streamlined and user-friendly manner.
Text Prompt
This feature allows you to prompt the user for a text input. The example code asks the user for their name and then greets them.
const { text } = require('@clack/prompts');
(async () => {
const name = await text({
message: 'What is your name?'
});
console.log(`Hello, ${name}!`);
})();
Select Prompt
This feature allows you to present a list of options for the user to select from. The example code asks the user to choose a color from a list of options.
const { select } = require('@clack/prompts');
(async () => {
const color = await select({
message: 'Choose a color',
choices: [
{ title: 'Red', value: 'red' },
{ title: 'Green', value: 'green' },
{ title: 'Blue', value: 'blue' }
]
});
console.log(`You chose ${color}.`);
})();
Confirm Prompt
This feature allows you to ask the user a yes/no question. The example code asks the user if they want to continue and logs a message based on their response.
const { confirm } = require('@clack/prompts');
(async () => {
const proceed = await confirm({
message: 'Do you want to continue?'
});
console.log(proceed ? 'Continuing...' : 'Operation aborted.');
})();
Password Prompt
This feature allows you to securely prompt the user for a password. The example code asks the user to enter their password and logs a confirmation message.
const { password } = require('@clack/prompts');
(async () => {
const secret = await password({
message: 'Enter your password:'
});
console.log('Password received.');
})();
Inquirer.js is a popular library for creating interactive command-line interfaces. It offers a wide range of prompt types and is highly customizable. Compared to @clack/prompts, Inquirer.js has a larger community and more extensive documentation.
Prompts is a lightweight, beautiful, and user-friendly library for creating command-line prompts. It supports various prompt types and is known for its simplicity and ease of use. While @clack/prompts focuses on a streamlined API, Prompts offers more customization options.
Enquirer is a powerful and flexible library for creating interactive command-line prompts. It supports a wide range of prompt types and offers advanced features like validation and conditional prompts. Enquirer is more feature-rich compared to @clack/prompts, but it may have a steeper learning curve.
@clack/prompts
FAQs
Effortlessly build beautiful command-line apps 🪄 [Try the demo](https://stackblitz.com/edit/clack-prompts?file=index.js)
We found that @clack/prompts demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.