Skip to content

⌨️ @reliverse/prompts: A modern, type-safe, crash-resistant library for creating seamless, typesafe prompts in CLI applications. Designed for simplicity and elegance, it enables intuitive and robust user interactions.

License

Notifications You must be signed in to change notification settings

reliverse/relinka

Repository files navigation

@reliverse/relinka

Docs | npmjs.com | GitHub

version downloads

@reliverse/relinka is a powerful library that enables seamless, type-safe, and resilient prompts for command-line applications. Crafted with simplicity and elegance, it provides developers with an intuitive and robust way to build interactive CLIs.

CLI Example

Installation

Install with your preferred package manager:

bun add @reliverse/relinka # Replace 'bun' with npm, pnpm, or yarn if desired (deno and jsr support coming soon)

Key Features

  • Type Safety: Built with TypeScript, ensuring strong typing to prevent runtime errors.
  • Schema Validation: Validates user inputs using schemas for enhanced reliability.
  • Flexible Prompt Types: Supports a range of prompt types, including text, password, number, select, and multiselect.
  • Crash Resilience: Designed to handle cancellations and errors gracefully, ensuring stability.

Confirm Prompt

Prompt Types

Each type has its own validation and display logic. More types are planned for future releases.

  • Text: Collects text input.
  • Password: Hidden input for secure password entries.
  • Number: Numeric input with optional validation.
  • Confirm: Simple Yes/No prompt.
  • Select: Dropdown selection for multiple choices.
  • Multiselect: Allows users to select multiple items from a list.

Multiselect Prompt

Input Validation

All prompts support custom validation logic, providing immediate feedback to users.

Number Prompt with Validation

Contributing

@reliverse/relinka is a work in progress. We welcome feedback and contributions to help make it the best library it can be. Thank you!

Here is how to install the library for development:

git clone https://github.com/reliverse/relinka.git
cd relinka
bun i

Playground

Run bun dev to launch the examples/run-example.ts CLI, where you can dive into and explore any of the examples listed below. Experiment with @reliverse/relinka by running examples locally or reviewing the linked code:

  1. 1-main-example.ts: A comprehensive example of a CLI application featuring a well styled UI config. This example showcases all available prompt components, with code organized into separate functions and files for better readability and clarity.
  2. 2-mono-example.ts: A quiz game example inspired by Fireship's video. It demonstrates the dynamic capabilities of @reliverse/relinka by using a prompt() that includes all prompt components, so you don't need to import each component separately.
  3. 3-basic-example.ts: A simple example highlighting the core functionalities of @reliverse/relinka. The entire implementation is contained within a single file for easy understanding.

Prompts Library Comparison

Note: This table contains approximate and placeholder values. More detailed assessments will be provided as libraries continue to evolve.

Icon Legend:

  • 🟡: Not yet verified
  • 🟢: Fully supported
  • 🔵: Partially supported
  • 🔴: Not supported
Feature @reliverse/relinka @inquirer/prompts @clack/prompts @terkelg/prompts @cronvel/terminal-kit @unjs/consola
Full Node.js Modules Support 🟢 Native ES module package 🟡 🟡 🔴 CJS-only 🔴 CJS-only 🟡
Both terminal and browser support 🟢 🟡 🟡 🟡 🟡 🟢
Codebase typesafety with intellisense 🔵 🟡 🟡 🟡 🟡 🟡
Runtime typesafety with schema validation 🟢 TypeBox & Custom 🟡 🟡 🟡 🟡 🟡
Usage Examples 🟢 🟡 🟡 🟡 🟡 🟡
Mono Component 🟢 Mono (All-In-One) & Separate 🟡 🟡 🔵 Mono-only 🟡 🟡
Start Component 🟢 🟡 🟡 🟡 🟡 🟡
Text Component 🟢 🟡 🟡 🟡 🟡 🟡
Customization 🟢 Colors, typography, variants, borders, and more 🟡 🟡 🟡 🟡 🟡
Visual Components: Separator, Animated Text, ASCII Art 🟢 Includes 6 animations and 290 ASCII fonts 🔵 Separator only 🟡 🟡 🟡 🟡
Password Component 🟡 🟡 🟡 🟡 🟡 🟡
Number Component 🟡 🟡 🟡 🟡 🟡 🟡
Confirm Component 🟡 🟡 🟡 🟡 🟡 🟡
Select Component 🟡 🟡 🟡 🟡 🟡 🟡
Multiselect Component 🟡 🟡 🟡 🟡 🟡 🟡
Search/Autocomplete Component 🔵 🟡 🟡 🟡 🟡 🟡
Spinner & Progressbar Components 🟡 🟡 🟡 🟡 🟢 🟡
Image Component 🟡 🟡 🟡 🟡 🟢 🟡
Custom Validation 🟡 🟡 🟡 🟡 🟡 🟡
Error Handling 🟡 🟡 🟡 🟡 🟡 🟡
Ease of Setup 🟡 🟡 🟡 🟡 🟡 🟡
Crash Resilience 🟡 🟡 🟡 🟡 🟡 🟡
General DX 🔵 Clean and understandable TypeScript code 🟡 🟡 🔴 JS-only 🔴 JS-only 🟡
DX: Classes 🟢 Minimal number of classes as possible 🟡 🟡 🟡 🟡 🟡
Documentation 🔵 🟡 🟡 🔵 🟢 🟡
Designed With UX in Mind 🔵 🟡 🟡 🟡 🟡 🟡

Related Links: ESM/CJS, "Pure ESM package", Clean code, "UX patterns for CLI tools", DX (Developer Experience), TypeBox, "ANSI Escape Sequences"

Wrap-Up

@reliverse/relinka is a versatile library designed to accelerate CLI development by providing customizable prompt components. Integrated into the Reliverse CLI, @reliverse/relinka enables you to create a unique design aligned with your CLI app’s aesthetics, similar to how @shadcn/ui supports customizable web UI components. Quickly get started by copying configurations from the Reliverse Docs and using components that fit your project, making it faster to bring your CLI app to life. You’re free to customize each component as desired, with default designs provided to ensure an attractive interface from the start.

Example Configuration:

const basicConfig = {
  titleColor: "cyanBright",
  titleTypography: "bold",
  borderColor: "viceGradient",
} satisfies OptionalPromptOptions;

const extendedConfig = {
  ...basicConfig,
  contentTypography: "italic",
  contentColor: "dim",
} satisfies OptionalPromptOptions;

const username = await textPrompt({
  id: "username",
  title: "We're glad you're testing our library!",
  content: "Let's get to know each other!\nWhat's your username?",
  schema: schema.properties.username,
  ...extendedConfig,
});

Separator

Learn More

Special Thanks

This project wouldn’t exist without the amazing work of the huge number of contributors to the list of projects below. Many of the @reliverse/relinka prompts are based on the incredible work of:

@inquirer/prompts | terkelg/prompts | @clack/prompts | create-t3-app | create-astro | cronvel/terminal-kit | unjs/consola | nodejs/string_decoder | TooTallNate/keypress | derhuerst

License

MIT © Nazarii Korniienko

About

⌨️ @reliverse/prompts: A modern, type-safe, crash-resistant library for creating seamless, typesafe prompts in CLI applications. Designed for simplicity and elegance, it enables intuitive and robust user interactions.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published