derive-survey
Derive interactive surveys for Rust types. Backend-agnostic.
This crate provides the #[derive(Survey)] macro for defining surveys
that can be collected through various backends (CLI wizards, GUI forms, etc.)
Usage
use Survey;
// Run the survey with a backend
let profile: UserProfile = builder
.suggest_name
.run
.unwrap;
Attributes
On structs and enums
#[prelude("...")]- Message shown before the survey starts#[epilogue("...")]- Message shown after the survey completes#[validate("fn_name")]- Composite validator function
On fields
#[ask("...")]- The prompt text shown to the user#[mask]- Hide input (for passwords)#[multiline]- Open text editor / show textarea#[validate("fn_name")]- Field-level validator function#[min(n)]/#[max(n)]- Numeric bounds#[multiselect]- ForVec<Enum>fields, enables multi-select
Backends
Backends are separate crates that implement SurveyBackend:
derive-requestty-wizard- CLI prompts via requesttyderive-dialoguer-wizard- CLI prompts via dialoguerderive-ratatui-wizard- TUI wizardderive-egui-form- GUI form via egui