Mode A: Cargo.toml Introspection
This example shows automatic provisioning generation from a Cargo.toml file.
What Gets Detected
From the included Cargo.toml, the generator detects:
Project Type
- WebService - detected from
axumdependency
Domain Features
- http_server - from
axumdependency- Fields:
bind_address,timeout_seconds
- Fields:
- authentication - from
jsonwebtokendependency- Fields:
jwt_secret(sensitive)
- Fields:
- caching - from
redisdependency- Fields:
cache_enabled,cache_ttl_seconds
- Fields:
Infrastructure
- Database: PostgreSQL (from
sqlxwith postgres feature)- Fields: host, port, username, password, database name
- SSH: Not required (no openssh-keys or ssh2)
- Monitoring: Prometheus detected (from
prometheusdependency) - Cloud Providers: Default to LXD
Running the Example
Step 1: Analyze the Cargo.toml
typedialog-provisioning-gen cargo \
--input examples/11-provisioning-generation/mode-a-cargo/Cargo.toml \
--output /tmp/my-provisioning
Step 2: Inspect Generated Structure
tree /tmp/my-provisioning
Expected output:
/tmp/my-provisioning/
├── config.ncl # Master configuration
├── constraints.toml # Validation bounds
├── schemas/ # Domain types
│ ├── http_server.ncl
│ ├── authentication.ncl
│ ├── caching.ncl
│ ├── database.ncl
│ ├── environment.ncl
│ └── ...
├── validators/ # Validation functions
│ ├── http_server.ncl
│ ├── authentication.ncl
│ ├── caching.ncl
│ ├── common.ncl
│ └── ...
├── defaults/ # Default values
│ ├── http_server.ncl
│ ├── authentication.ncl
│ ├── caching.ncl
│ ├── database.ncl
│ └── ...
├── fragments/ # TypeDialog forms
│ ├── http_server-section.toml
│ ├── authentication-section.toml
│ ├── caching-section.toml
│ ├── database-mysql-section.toml
│ └── ...
└── scripts/ # Orchestration
├── config.sh
├── config.nu
├── json-to-nickel.sh
├── validate-nickel.sh
└── ...
Step 3: Validate Generated Configuration
cd /tmp/my-provisioning
./scripts/validate-nickel.sh
Step 4: Use in TypeDialog Forms
# Display HTTP server configuration form
typedialog fragments/http_server-section.toml --backend cli
# Display database configuration form
typedialog fragments/database-mysql-section.toml --backend cli
Dependency → Feature Mapping
The generator uses these heuristics:
| Dependency | Feature | Fields |
|---|---|---|
| axum, actix-web, rocket | http_server | bind_address, timeout_seconds |
| jsonwebtoken, oauth2 | authentication | jwt_secret |
| redis, memcache | caching | cache_enabled, cache_ttl_seconds |
| sqlx, mysql, postgres | database | host, port, username, password |
| prometheus | monitoring | scrape_interval, retention_time |
| grafana | dashboard | admin_password |
| openssh-keys, ssh2 | ssh | private_key_path, username, port |
Customization
To override the detection, use Mode B (config file) with custom features:
- Generate initial config from Cargo.toml
- Edit the config file to add/modify features
- Re-generate with Mode B
See ../mode-b-config/ for the config file format.
What This Demonstrates
✅ Automatic feature detection from dependencies ✅ Type inference (WebService detected from web frameworks) ✅ Infrastructure requirements (database, monitoring setup) ✅ Complete 7-layer validation stack generation ✅ Integration with TypeDialog forms ✅ Reusable template library (generic validators, schemas, etc.)
Next Steps
- Modify Configuration: Edit generated
config.nclto customize - Add Custom Fields: Create domain-specific fields in generated fragments
- Deploy: Use
config.shorconfig.nuscripts for orchestration - Integrate: Import generated schemas in your application configuration