$git clone https://github.com/mikaelmello/inquire[![Latest Version]][crates.io] [![Docs]][docs.rs] ![Build status] ![Unsafe forbidden] ![Supported platforms] ![License]
| 1 | [![Latest Version]][crates.io] [![Docs]][docs.rs] ![Build status] ![Unsafe forbidden] ![Supported platforms] ![License] |
| 2 | |
| 3 | [crates.io]: https://crates.io/crates/inquire |
| 4 | [latest version]: https://img.shields.io/crates/v/inquire.svg |
| 5 | [docs]: https://img.shields.io/docsrs/inquire/latest?logo=docs.rs |
| 6 | [docs.rs]: https://docs.rs/inquire |
| 7 | [build status]: https://github.com/mikaelmello/inquire/actions/workflows/build.yml/badge.svg |
| 8 | [unsafe forbidden]: https://img.shields.io/badge/unsafe-forbidden-success.svg |
| 9 | [supported platforms]: https://img.shields.io/badge/platform-linux%20%7C%20macos%20%7C%20windows-success |
| 10 | [license]: https://img.shields.io/crates/l/inquire.svg |
| 11 | |
| 12 | --- |
| 13 | |
| 14 | <p align="center"> |
| 15 | <img width="460" src="./assets/inquire.png"> |
| 16 | <br> |
| 17 | <code>inquire</code> is a library for building interactive prompts on terminals. |
| 18 | </p> |
| 19 | |
| 20 | It provides several different prompts in order to interactively ask the user for information via the CLI. With `inquire`, you can use: |
| 21 | |
| 22 | - [`Text`] to get text input from the user, with _built-in autocompletion support_; |
| 23 | - [`Editor`]\* to get longer text inputs by opening a text editor for the user; |
| 24 | - [`DateSelect`]\* to get a date input from the user, selected via an _interactive calendar_; |
| 25 | - [`Select`] to ask the user to select one option from a given list; |
| 26 | - [`MultiSelect`] to ask the user to select an arbitrary number of options from a given list; |
| 27 | - [`Confirm`] for simple yes/no confirmation prompts; |
| 28 | - [`CustomType`] for text prompts that you would like to parse to a custom type, such as numbers or UUIDs; |
| 29 | - [`Password`] for secretive text prompts. |
| 30 | |
| 31 | --- |
| 32 | |
| 33 | ## Demo |
| 34 | |
| 35 |  |
| 36 | [Source](./examples/expense_tracker.rs) |
| 37 | |
| 38 | ## Features |
| 39 | |
| 40 | - Cross-platform, supporting UNIX and Windows terminals (thanks to [crossterm](https://crates.io/crates/crossterm)); |
| 41 | - Several kinds of prompts to suit your needs; |
| 42 | - Standardized error handling (thanks to [thiserror](https://crates.io/crates/thiserror)); |
| 43 | - You can choose your terminal backend between `crossterm` (default), `termion` or `console`. |
| 44 | - Perfect if you already use one library and do not want additional dependencies. |
| 45 | - Support for fine-grained configuration for each prompt type, allowing you to customize: |
| 46 | - Rendering configuration (aka color theme + other components); |
| 47 | - Default values; |
| 48 | - Placeholders; |
| 49 | - Input validators and formatters; |
| 50 | - Help messages; |
| 51 | - Autocompletion for [`Text`] prompts; |
| 52 | - Confirmation messages for [`Password`] prompts; |
| 53 | - Custom list filters for [`Select`] and [`MultiSelect`] prompts; |
| 54 | - Custom parsers for [`Confirm`] and [`CustomType`] prompts; |
| 55 | - Custom extensions for files created by [`Editor`] prompts; |
| 56 | - and many others! |
| 57 | |
| 58 | ## Examples |
| 59 | |
| 60 | Examples can be found in the `examples` directory. Run them to see basic behavior: |
| 61 | |
| 62 | ```bash |
| 63 | cargo run --example expense_tracker -p inquire-examples |
| 64 | ``` |
| 65 | |
| 66 | ## Usage |
| 67 | |
| 68 | Put this line in your `Cargo.toml`, under `[dependencies]`. |
| 69 | |
| 70 | ```toml |
| 71 | inquire = "0.9.4" |
| 72 | ``` |
| 73 | |
| 74 | \* This prompt type is gated under a feature flag, e.g.: |
| 75 | |
| 76 | ```toml |
| 77 | inquire = { version = "0.9.4", features = ["date"] } |
| 78 | ``` |
| 79 | |
| 80 | # Cross-cutting concerns |
| 81 | |
| 82 | There are several features that are shared among different types of prompts. This section will give an overview on each of them. |
| 83 | |
| 84 | ## Rendering configuration (aka color themes) |
| 85 | |
| 86 | All prompts allow you to set a custom `RenderConfig`, a struct that contains lots of style customization options. |
| 87 | |
| 88 | With `RenderConfig`, you can customize foreground color, background color and attributes (e.g. bold) of most components that are part of a prompt. Additionally, you can also customize the content of special tokens, such as prompt prefixes, highlighted-option prefixes, selected and unselected checkboxes, etc. If you do not want to re-set the render config object for each new prompt you create, you ca |