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

#40 in #apps

MIT license

195KB
1.5K SLoC

Contributors Forks Stargazers Issues MIT License LinkedIn


cli_prompt_rs

Easily build beautiful command-line apps
Explore the docs »

View Demo · Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. Contributing
  6. License
  7. Acknowledgments

About The Project

Product Name Screen Shot

Inspired by @clack/prompts, This library provides easy-to-use CLI prompt functions to help you build beautiful command-line-apps easily.

(back to top)

Built With

  • Rust

(back to top)

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"

(back to top)

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

(back to top)

Roadmap

  • Multiple Choice
  • Print memo
  • Color / style utils

See the open issues for a full list of proposed features (and known issues).

(back to top)

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!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

This project uses conventional commits to automating publish process.

(back to top)

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Acknowledgments

(back to top)

Dependencies

~1–11MB
~65K SLoC