Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@clack/prompts

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@clack/prompts - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

6

CHANGELOG.md
# @clack/prompts
## 0.0.5
### Patch Changes
- Update README
## 0.0.4

@@ -4,0 +10,0 @@

2

package.json
{
"name": "@clack/prompts",
"version": "0.0.4",
"version": "0.0.5",
"type": "module",

@@ -5,0 +5,0 @@ "main": "./dist/index.js",

@@ -16,2 +16,89 @@ # `@clack/prompts`

## Basics
### Setup
The `intro` and `outro` functions will print a message to begin or end a prompt session, respectively.
```js
import { intro, outro } from "@clack/prompts";
intro(`create-my-app`);
// Do stuff
outro(`You're all set!`);
```
### Cancellation
The `isCancel` function is a guard that detects when a user cancels a question with `CTRL + C`. You should handle this situation for each prompt, optionally providing a nice cancellation message with the `cancel` utility.
```js
import { isCancel, cancel, text } from "@clack/prompts";
const value = await text(/* TODO */);
if (isCancel(value)) {
cancel("Operation cancelled.");
process.exit(0);
}
```
## Components
### Text
The text component accepts a single line of text.
```js
import { text } from "@clack/prompts";
const meaning = await text({
message: "What is the meaning of life?",
placeholder: "Not sure",
validate(value) {
if (value.length === 0) return `Value is required!`;
},
});
```
### Confirm
The confirm component accepts a yes or no answer. The result is a boolean value of `true` or `false`.
```js
import { confirm } from "@clack/prompts";
const shouldContinue = await confirm({
message: "Do you want to continue?",
});
```
### Select
The select component allows a user to choose one value from a list of options. The result is the `value` prop of a given option.
```js
import { select } from "@clack/prompts";
const projectType = await select({
message: "Pick a project type.",
options: [
{ value: "ts", label: "TypeScript" },
{ value: "js", label: "JavaScript" },
{ value: "coffee", label: "CoffeeScript", hint: "oh no" },
],
});
```
### Spinner
The spinner component surfaces a pending action, such as a long-running download or dependency installation.
```js
import { spinner } from "@clack/prompts";
const s = spinner();
s.start("Installing via npm");
// Do installation
s.stop("Installed via npm");
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc