Crates.io | cli_prompts_rs |
lib.rs | cli_prompts_rs |
version | 0.3.0 |
source | src |
created_at | 2023-10-07 12:42:34.576072 |
updated_at | 2024-02-14 10:14:36.828654 |
description | Easily build beautiful command-line apps |
homepage | |
repository | https://github.com/probaku1234/cli_prompt_rs |
max_upload_size | |
id | 996291 |
size | 280,637 |
Easily build beautiful command-line apps
Explore the docs »
View Demo
·
Report Bug
·
Request Feature
Inspired by @clack/prompts, This library provides easy-to-use CLI prompt functions to help you build beautiful command-line-apps easily.
Run the following Cargo command in your project directory:
cargo add cli_prompts_rs
Or add the following line to your Cargo.toml:
cli_prompts_rs = "0.2.0"
Here is basic example.
use cli_prompts_rs::{CliPrompt, LogType, PromptSelectOption};
use std::process::exit;
fn main() {
let mut cli_prompt = CliPrompt::new();
cli_prompt.intro("example app").unwrap();
cli_prompt.prompt_text("Enter your name").unwrap();
let answer = cli_prompt.prompt_confirm("Are you sure?").unwrap();
if !answer {
cli_prompt.cancel("Operation cancelled").unwrap();
exit(0);
}
let options = vec![
PromptSelectOption::new("option1", "Pikachu"),
PromptSelectOption::new("option2", "Charmander"),
PromptSelectOption::new("option3", "Squirtle"),
];
let selected_option = cli_prompt
.prompt_select("Which one do you prefer?", options)
.unwrap();
cli_prompt
.log(&format!("{}", selected_option), LogType::Info)
.unwrap();
cli_prompt.outro("Good Bye").unwrap();
}
For more examples, please refer to the Documentation
Multiple Choice
Print memo
Color / style utils
See the open issues for a full list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
git checkout -b feature/AmazingFeature
)git commit -m 'Add some AmazingFeature'
)git push origin feature/AmazingFeature
)This project uses conventional commits to automating publish process.
Distributed under the MIT License. See LICENSE.txt
for more information.