elicitor 0.6.0

Derive interactive surveys for Rust types. Backend-agnostic. Backends are provided in elicitor-wizard-requestty, elicitor-wizard-ratatui, elicitor-form-egui, and many others.
Documentation

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 elicitor::Survey;

#[derive(Survey, Debug)]
struct UserProfile {
    #[ask("What is your name?")]
    name: String,

    #[ask("How old are you?")]
    #[min(0)]
    #[max(150)]
    age: u32,

    #[ask("Are you a student?")]
    student: bool,
}

// Run the survey with a backend
let profile: UserProfile = UserProfile::builder()
    .suggest_name("Alice")
    .run(backend)
    .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] - For Vec<Enum> fields, enables multi-select

Backends

Backends are separate crates that implement SurveyBackend:

  • derive-requestty-wizard - CLI prompts via requestty
  • derive-dialoguer-wizard - CLI prompts via dialoguer
  • derive-ratatui-wizard - TUI wizard
  • derive-egui-form - GUI form via egui