#prompt #interactive #ask #input-validation #questions #cli #text-editors

oma-inquire

inquire is a library for building interactive prompts on terminals

4 releases

0.2.1 Dec 9, 2024
0.2.0 Dec 9, 2024
0.1.1 Aug 8, 2023
0.1.0 Aug 8, 2023

#113 in Value formatting

Download history 371/week @ 2024-09-29 170/week @ 2024-10-06 227/week @ 2024-10-13 176/week @ 2024-10-20 656/week @ 2024-10-27 412/week @ 2024-11-03 408/week @ 2024-11-10 424/week @ 2024-11-17 546/week @ 2024-11-24 214/week @ 2024-12-01 589/week @ 2024-12-08 521/week @ 2024-12-15 617/week @ 2024-12-22 330/week @ 2024-12-29 282/week @ 2025-01-05 137/week @ 2025-01-12

1,485 downloads per month
Used in oma-topics

MIT license

175KB
3K SLoC

Latest Version Build status Supported platforms License



inquire is a library for building interactive prompts on terminals.

It provides several different prompts in order to interactively ask the user for information via the CLI. With inquire, you can use:

  • Text to get text input from the user, with built-in autocompletion support;
  • Editor* to get longer text inputs by opening a text editor for the user;
  • DateSelect* to get a date input from the user, selected via an interactive calendar;
  • Select to ask the user to select one option from a given list;
  • MultiSelect to ask the user to select an arbitrary number of options from a given list;
  • Confirm for simple yes/no confirmation prompts;
  • CustomType for text prompts that you would like to parse to a custom type, such as numbers or UUIDs;
  • Password for secretive text prompts.

Demo

Animated GIF making a demonstration of a questionnaire created with this library. You can replay this recording in your terminal with asciinema play command - asciinema play ./assets/expense_tracker.cast Source

Features

  • Cross-platform, supporting UNIX and Windows terminals (thanks to crossterm);
  • Several kinds of prompts to suit your needs;
  • Standardized error handling (thanks to thiserror);
  • Support for fine-grained configuration for each prompt type, allowing you to customize:
    • Default values;
    • Input validators and formatters;
    • Help messages;
    • Autocompletion for Text prompts;
    • Custom list filters for Select and MultiSelect prompts;
    • Custom parsers for Confirm and CustomType prompts;
    • Custom extensions for files created by Editor prompts;
    • and many others!

Usage

Put this line in your Cargo.toml, under [dependencies].

inquire = "0.6.1"

* This prompt type is gated under a feature flag, e.g.:

inquire = { version = "0.6.1", features = ["date", "editor"] }

Dependencies

~4–14MB
~183K SLoC