zenquirer 0.1.0

Interactive command-line questionnaires and prompts with async support
Documentation

zenquirer

Zenquirer is a serialization-first, async-first Rust library for interactive command-line questionnaires and prompts.

Most users should depend on this crate. It re-exports the platform-agnostic zenquirer-core API and includes the zenquirer-crossterm terminal backend by default.

Highlights

  • 15 serializable question types for QuestionnaireBuilder
  • Dynamic runtime questions through AsyncScope
  • Typed answer extraction with Answers::get_as::<T>()
  • Full YAML/JSON questionnaire and answer serialization
  • 50+ validators with combinator support
  • Mock backend support for tests
  • Optional zenq CLI for YAML/JSON questionnaire files

Install

[dependencies]
zenquirer = "0.1"

Enable the CLI binary when installing the tool:

cargo install zenquirer --features cli

Example

use zenquirer::{CrosstermBackend, QuestionnaireBuilder, QuestionnaireExt, Validator};

fn main() -> Result<(), zenquirer::Error> {
    zenquirer::smol::block_on(async {
        let backend = CrosstermBackend::new()?;
        let survey = QuestionnaireBuilder::new()
            .select("language", "Choose language")
            .options(["Rust", "Python", "Go"])
            .input("email", "Enter your email")
            .validator(Validator::email())
            .build();

        let answers = survey.ask_all_async(backend, None).await?;
        let language = answers.get_as::<&str>("language")?;
        println!("Selected: {language}");
        Ok(())
    })
}

Feature flags

Feature Default Description
crossterm yes Terminal backend
validators-regex yes Regex-backed validators
datetime no Typed Date and DateTime answers
datetime-tz no Timezone-aware DateTimeTz answers
cli no zenq CLI binary
schema no JSON Schema generation

Documentation

License

MIT OR Apache-2.0