#cli #ask #prompt #question #interactive

inquire

inquire is a library for building interactive prompts on terminals

13 releases

0.2.0 Sep 14, 2021
0.1.0 Sep 14, 2021
0.0.11 Sep 6, 2021
0.0.10 Aug 29, 2021
0.0.2 Jun 26, 2021

#92 in Command-line interface

Download history 22/week @ 2021-06-20 16/week @ 2021-06-27 14/week @ 2021-07-04 15/week @ 2021-07-11 24/week @ 2021-07-18 90/week @ 2021-07-25 17/week @ 2021-08-01 39/week @ 2021-08-08 153/week @ 2021-08-15 41/week @ 2021-08-22 56/week @ 2021-08-29 25/week @ 2021-09-05 58/week @ 2021-09-12 27/week @ 2021-09-19

179 downloads per month
Used in cc-cli

MIT license

275KB
5K 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 auto-completion 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;
    • Auto-completion 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.2.0"

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

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

Dependencies

~1.6–2.7MB
~52K SLoC