cli_prompts/
lib.rs

1#![allow(dead_code)]
2
3//! # Interactive CLI prompts in Rust
4//! 
5//! Create interactive input prompts like in [GitHub's CLI tool](https://cli.github.com/).
6//! 
7//! ## Features
8//! 
9//! - Cross-platform;
10//! - Only one dependency - [crossterm](https://github.com/crossterm-rs/crossterm);
11//! - 4 prompts out of the box:
12//!   - Normal input field. Supports input validation and default values;
13//!   - Confirmation y/n;
14//!   - Selection from the list of options;
15//!   - Multiselection.
16//! - Customization of the colors and text style of the prompts;
17//! - Set of traits and helper structs that allows to implement custom prompts for your application;
18//! 
19//! ## Getting started
20//! 
21//! ```rust
22//!     use cli_prompts::{
23//!         prompts::{Input, AbortReason},
24//!         DisplayPrompt
25//!     };
26//! 
27//!     fn show_input_prompt() {
28//!       let name : Result<String, AbortReason> = Input::new("Enter your name", name_validation)
29//!           .default_value("John")
30//!           .help_message("Please provide your real name")
31//!           .display();
32//! 
33//!       match name {
34//!           Ok(n) => println!("The name is {}", n),
35//!           Err(abort_reason) => println!("Input was aborted because of {:?}", abort_reason),
36//!       }
37//!     }
38//! 
39//!     fn name_validation(name: &str) -> Result<String, String> {
40//!       if name.len() > 0 {
41//!           Ok(name.to_string())
42//!       } else {
43//!           Err("Name must not be empty".into())
44//!       }
45//!     }
46//! 
47//! ```
48//! 
49//! ## License
50//! This project, cli_prompts is licensed under the MIT License
51
52
53pub mod engine;
54pub mod prompts;
55pub mod style;
56pub mod input;
57
58pub use prompts::DisplayPrompt;