inquire-derive
Derive macros for the inquire crate.
Usage
Put these lines in your Cargo.toml, under [dependencies].
= "0.9.2"
= "0.9.2"
Then use the Selectable derive macro on your enums:
use Selectable;
use ;
// Now you can use:
let color = select.prompt?;
let colors = multi_select.prompt?;
Features
The Selectable derive macro generates two methods for your enum:
select(msg: &str)- Returns aSelectbuilder for single selectionmulti_select(msg: &str)- Returns aMultiSelectbuilder for multiple selection
Both methods return builders that can be customized before calling .prompt():
let color = select
.with_help_message
.with_page_size
.prompt?;
let colors = multi_select
.with_default // Pre-select first two options
.with_help_message
.prompt?;
Examples
Run the examples to see the derive macro in action:
Requirements
Your enum must implement:
Display- for showing options to the userDebug- required by inquireCopyandClone- for efficient handling- Be
'static- for the generated code