199 lines
4.5 KiB
TOML
199 lines
4.5 KiB
TOML
# Conditional Logic Demo
|
|
# Demonstrates all supported conditional operators in TypeDialog
|
|
|
|
name = "conditional_demo"
|
|
description = "Complete demonstration of conditional field visibility"
|
|
|
|
# ====================
|
|
# COMPARISON OPERATORS
|
|
# ====================
|
|
|
|
[[elements]]
|
|
name = "database_driver"
|
|
type = "select"
|
|
prompt = "Select database driver"
|
|
required = true
|
|
options = [
|
|
{ value = "sqlite", label = "SQLite (embedded)" },
|
|
{ value = "mysql", label = "MySQL" },
|
|
{ value = "postgresql", label = "PostgreSQL" }
|
|
]
|
|
|
|
# Equality (==)
|
|
[[elements]]
|
|
name = "mysql_config"
|
|
type = "text"
|
|
prompt = "MySQL connection string"
|
|
when = "database_driver == mysql"
|
|
placeholder = "mysql://localhost:3306/db"
|
|
|
|
# Inequality (!=)
|
|
[[elements]]
|
|
name = "server_warning"
|
|
type = "section"
|
|
content = "⚠️ You selected a server-based database. Ensure the server is running."
|
|
when = "database_driver != sqlite"
|
|
|
|
# ====================
|
|
# NUMERIC COMPARISONS
|
|
# ====================
|
|
|
|
[[elements]]
|
|
name = "server_port"
|
|
type = "text"
|
|
prompt = "Server port"
|
|
default = "8080"
|
|
required = true
|
|
|
|
# Greater than (>)
|
|
[[elements]]
|
|
name = "high_port_warning"
|
|
type = "section"
|
|
content = "⚠️ Port > 10000 is uncommon. Double-check your configuration."
|
|
when = "server_port > 10000"
|
|
|
|
# Less than (<)
|
|
[[elements]]
|
|
name = "privileged_port_warning"
|
|
type = "section"
|
|
content = "⚠️ Port < 1024 requires root/admin privileges."
|
|
when = "server_port < 1024"
|
|
|
|
# Greater than or equal (>=)
|
|
[[elements]]
|
|
name = "standard_port_notice"
|
|
type = "section"
|
|
content = "✓ Using standard user port range (>= 1024)"
|
|
when = "server_port >= 1024"
|
|
|
|
# Less than or equal (<=)
|
|
[[elements]]
|
|
name = "low_port_range"
|
|
type = "section"
|
|
content = "Using low port range (<= 5000)"
|
|
when = "server_port <= 5000"
|
|
|
|
# ====================
|
|
# STRING OPERATORS
|
|
# ====================
|
|
|
|
[[elements]]
|
|
name = "project_url"
|
|
type = "text"
|
|
prompt = "Project repository URL"
|
|
placeholder = "https://github.com/user/repo"
|
|
|
|
# startswith
|
|
[[elements]]
|
|
name = "https_notice"
|
|
type = "section"
|
|
content = "✓ Secure HTTPS URL detected"
|
|
when = "project_url startswith https"
|
|
|
|
# endswith
|
|
[[elements]]
|
|
name = "github_specific"
|
|
type = "text"
|
|
prompt = "GitHub Actions enabled?"
|
|
when = "project_url endswith github.com"
|
|
|
|
# contains
|
|
[[elements]]
|
|
name = "gitlab_ci"
|
|
type = "confirm"
|
|
prompt = "Enable GitLab CI integration?"
|
|
when = "project_url contains gitlab"
|
|
|
|
# ====================
|
|
# ARRAY MEMBERSHIP (in)
|
|
# ====================
|
|
|
|
[[elements]]
|
|
name = "detected_languages"
|
|
type = "multiselect"
|
|
prompt = "Which languages are used in your project?"
|
|
display_mode = "grid"
|
|
options = [
|
|
{ value = "rust", label = "🦀 Rust" },
|
|
{ value = "python", label = "🐍 Python" },
|
|
{ value = "javascript", label = "📜 JavaScript" },
|
|
{ value = "go", label = "🐹 Go" }
|
|
]
|
|
|
|
# Array membership check
|
|
[[elements]]
|
|
name = "rust_toolchain"
|
|
type = "select"
|
|
prompt = "Rust toolchain version"
|
|
when = "rust in detected_languages"
|
|
options = [
|
|
{ value = "stable", label = "Stable" },
|
|
{ value = "nightly", label = "Nightly" },
|
|
{ value = "beta", label = "Beta" }
|
|
]
|
|
|
|
[[elements]]
|
|
name = "python_venv"
|
|
type = "confirm"
|
|
prompt = "Use Python virtual environment?"
|
|
when = "python in detected_languages"
|
|
default = true
|
|
|
|
[[elements]]
|
|
name = "nodejs_version"
|
|
type = "select"
|
|
prompt = "Node.js version"
|
|
when = "javascript in detected_languages"
|
|
options = [
|
|
{ value = "18", label = "Node.js 18 LTS" },
|
|
{ value = "20", label = "Node.js 20 LTS" },
|
|
{ value = "latest", label = "Latest" }
|
|
]
|
|
|
|
# ====================
|
|
# FILE SYSTEM CONDITIONS
|
|
# ====================
|
|
|
|
# file_exists(path)
|
|
[[elements]]
|
|
name = "dockerfile_exists_notice"
|
|
type = "section"
|
|
content = "✓ Dockerfile found in current directory"
|
|
when = "file_exists(Dockerfile)"
|
|
|
|
# !file_exists(path) - negation
|
|
[[elements]]
|
|
name = "create_dockerfile"
|
|
type = "confirm"
|
|
prompt = "No Dockerfile found. Create one?"
|
|
when = "!file_exists(Dockerfile)"
|
|
default = true
|
|
|
|
[[elements]]
|
|
name = "use_existing_config"
|
|
type = "confirm"
|
|
prompt = "Existing .env file found. Use existing configuration?"
|
|
when = "file_exists(.env)"
|
|
|
|
[[elements]]
|
|
name = "env_setup"
|
|
type = "group"
|
|
includes = ["fragments/environment-setup.toml"]
|
|
when = "!file_exists(.env)"
|
|
|
|
# ====================
|
|
# COMBINED CONDITIONS
|
|
# ====================
|
|
|
|
[[elements]]
|
|
name = "rust_docker_setup"
|
|
type = "section"
|
|
content = "🦀 Rust + Docker detected. Consider using rust:alpine base image."
|
|
when = "rust in detected_languages"
|
|
|
|
[[elements]]
|
|
name = "production_ready_check"
|
|
type = "section"
|
|
content = "✅ Production-ready configuration detected (HTTPS + standard port)"
|
|
when = "server_port >= 1024"
|