cli_prompts_rs

Crates.iocli_prompts_rs
lib.rscli_prompts_rs
version0.3.0
sourcesrc
created_at2023-10-07 12:42:34.576072
updated_at2024-02-14 10:14:36.828654
descriptionEasily build beautiful command-line apps
homepage
repositoryhttps://github.com/probaku1234/cli_prompt_rs
max_upload_size
id996291
size280,637
Yun Seob Lee (probaku1234)

documentation

README

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)

Commit count: 36

cargo fmt