Nickel Integration
Type-safe form schema generation and roundtrip workflows using Nickel configuration language.
Files
- nickel_schema.ncl - Type-safe form schema definition
- nickel_template.ncl.j2 - Jinja2 template for schema generation
About Nickel
Nickel is a powerful configuration language that provides:
- Strong typing
- Validation rules
- Reusable schemas
- Inheritance and composition
- Roundtrip support - Edit existing configs via forms
Usage
Generate Form from Nickel Schema
# Process template through Jinja2
j2 nickel_template.ncl.j2 > form_schema.ncl
# Generate TOML from Nickel
nickel eval nickel_schema.ncl > form_config.toml
# Run form
cargo run -p typedialog-web -- --config form_config.toml
Roundtrip Workflow (Edit Existing Configs)
New! Edit existing Nickel configurations through interactive forms:
# CLI backend (command-line prompts)
typedialog nickel-roundtrip \
--input config.ncl \
--form ci-form.toml \
--output config.ncl \
--ncl-template config.ncl.j2
# TUI backend (full-screen terminal UI)
typedialog-tui nickel-roundtrip \
--input config.ncl \
--form ci-form.toml \
--output config.ncl \
--ncl-template config.ncl.j2
# Web backend (browser-based form with HTML diff)
typedialog-web nickel-roundtrip \
--input config.ncl \
--form ci-form.toml \
--output config.ncl \
--ncl-template config.ncl.j2
Features:
- ✓ Load existing values from
.nclfiles - ✓ Pre-populate form fields with current config
- ✓ Generate new
.nclusing templates - ✓ Show diff summary (what changed)
- ✓ Automatic validation with
nickel typecheck - ✓ HTML summary page (web backend only)
See complete example: ../08-nickel-roundtrip/
Example Nickel Schema
{
form = {
title = "Registration",
fields = {
email = {
type = "email",
required = true,
label = "Email Address",
}
}
}
}
Benefits
- Type Safety - Catch schema errors at compile time
- Inheritance - Reuse common field definitions
- Validation - Built-in schema validation
- Macros - Generate repetitive fields
- Documentation - Self-documenting schemas
Advanced Features
- Field inheritance - Reuse common field definitions
- Custom validators - Built-in schema validation
- Conditional schemas - Dynamic form generation
- Template-driven generation - Tera template support
- Schema composition - Combine multiple schemas
- Roundtrip editing - Edit existing configs via forms (NEW!)
- Diff viewer - See what changed after editing (NEW!)