Skip to main content

Crate promkit

Crate promkit 

Source
Expand description

§promkit

ci docs.rs

A toolkit for building your own interactive prompt in Rust.

§Getting Started

Put the package in your Cargo.toml.

[dependencies]
promkit = "0.12.0"

§Features

  • Cross-platform support for both UNIX and Windows utilizing crossterm
  • Modularized architecture
    • promkit-core
      • Core functionality for terminal rendering and keyed grapheme chunk management
    • promkit-widgets
      • Various UI components (text, listbox, tree, etc.)
    • promkit
      • High-level presets and user interfaces
    • promkit-derive
      • A Derive macro that simplifies interactive form input
  • Rich preset components
    • Readline - Text input with auto-completion
    • Confirm - Yes/no confirmation prompt
    • Password - Password input with masking and validation
    • Form - Manage multiple text input fields
    • Listbox - Single selection interface from a list
    • QuerySelector - Searchable selection interface
    • Checkbox - Multiple selection checkbox interface
    • Tree - Tree display for hierarchical data like file systems
    • JSON - Parse and interactively display JSON data
    • Text - Static text display

§Concept

See here.

§Projects using promkit

§Examples/Demos

promkit provides presets so that users can try prompts immediately without having to build complex components for specific use cases.

Show you commands, code, and actual demo screens for examples that can be executed immediately below.

§Readline

Command
cargo run --bin readline

Code

§Confirm

Command
cargo run --bin confirm

Code

§Password

Command
cargo run --bin password

Code

§Form

Command
cargo run --bin form

Code

§Listbox

Command
cargo run --bin listbox

Code

§QuerySelector

Command
cargo run --bin query_selector

Code

§Checkbox

Command
cargo run --bin checkbox

Code

§Tree

Command
cargo run --bin tree

Code

§JSON

Command
cargo run --bin json ${PATH_TO_JSON_FILE}

Code

§Text

Command
cargo run --bin text

Code

§License

MIT License

§Stargazers over time

Stargazers over time

Re-exports§

pub use anyhow;
pub use async_trait;
pub use promkit_widgets as widgets;
pub use promkit_widgets::core;

Modules§

preset
suggest
validate

Enums§

Signal
Represents the signal to control the flow of a prompt.

Statics§

EVENT_STREAM
Singleton for EventStream. If a new EventStream is created for each Prompt::run, it causes the error “The cursor position could not be read within a normal duration”. See https://github.com/crossterm-rs/crossterm/issues/963#issuecomment-2571259264 for more details.

Traits§

Prompt
A trait for rendering components within a prompt.