4 releases (2 breaking)
0.3.0 | Feb 14, 2024 |
---|---|
0.2.0 | Oct 11, 2023 |
0.1.1 | Oct 9, 2023 |
0.1.0 | Oct 7, 2023 |
#32 in #apps
195KB
1.5K
SLoC
cli_prompt_rs
Easily build beautiful command-line apps
Explore the docs »
View Demo
·
Report Bug
·
Request Feature
Table of Contents
About The Project
Inspired by @clack/prompts, This library provides easy-to-use CLI prompt functions to help you build beautiful command-line-apps easily.
Built With
Getting Started
Installation
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"
Usage
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
Roadmap
- Multiple Choice
- Print memo
- Color / style utils
See the open issues for a full list of proposed features (and known issues).
Contributing
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!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
This project uses conventional commits to automating publish process.
License
Distributed under the MIT License. See LICENSE.txt
for more information.
Acknowledgments
Dependencies
~1.3–7.5MB
~57K SLoC