Create beautiful, interactive command-line forms and configuration wizards using YAML flow definitions.
CRITICAL-SIGNAL-HANDLING-ISSUE.md BEFORE USING IN PRODUCTION.
Status: Documented with workarounds available. Fix is Priority 0 in backlog.
TUI Form Designer is split into two packages for optimal deployment flexibility:
- Lightweight runtime for executing flows in production
- Minimal dependencies - only questionary, pyyaml, pydantic
- Fast startup and stable API
- Perfect for production environments
pip install tui-form-engine- Complete development toolkit for creating and managing flows
- Interactive designer, testing framework, validation tools
- CLI interface with comprehensive commands
- Perfect for development environments
pip install tui-form-editor # Includes tui-form-engine| Environment | Package | Use Case |
|---|---|---|
| Production | tui-form-engine |
Running flows in deployed applications |
| Development | tui-form-editor |
Creating, testing, and managing flows |
| CI/CD | tui-form-editor |
Validation and testing in pipelines |
| Docker | tui-form-engine |
Minimal container size for runtime |
- π YAML-Defined Forms: Define interactive workflows in human-readable YAML
- π¨ Interactive Designer: Visual form creation using Questionary itself
- π Comprehensive Validation: Syntax and logic validation with detailed error reporting
- π§ͺ Testing Framework: Automated testing with mock responses
- β‘ CLI Tools: Complete command-line toolkit for form management
- π Theming Support: Multiple built-in themes and custom styling
- π Conditional Logic: Advanced branching and conditional questions
- π Real-time Validation: Input validation with immediate feedback
- ποΈ Output Mapping: Transform responses to structured data
- π Easy Integration: Simple Python API for embedding in applications
- π― Rich UI Elements: 7 step types including text, select, multiselect, confirm, password, info, and computed
- π Advanced Input Handling: Built-in validators, pattern matching, and custom error messages
pip install tui-form-designer# Interactive mode - explore all tools
tui-designer
# Create a new form interactively
tui-designer design
# Preview existing forms
tui-designer preview --list
# Validate form definitions
tui-designer validate
# Test forms with mock data
tui-designer test --interactive
# Run demo with examples
tui-designer demofrom tui_form_designer import FlowEngine
# Initialize the engine
engine = FlowEngine(flows_dir="my_tui_layouts")
# Execute a form
results = engine.execute_flow("user_registration")
print(f"User: {results['username']}")
# Execute with mock responses for testing
mock_data = {"username": "testuser", "email": "test@example.com"}
results = engine.execute_flow("user_registration", mock_responses=mock_data)Create beautiful forms with simple YAML:
layout_id: "user_survey"
title: "User Satisfaction Survey"
description: "Quick survey to gather user feedback"
icon: "π"
steps:
- id: "user_name"
type: "text"
message: "What's your name?"
validate: "required"
- id: "satisfaction"
type: "select"
message: "How satisfied are you with our service?"
choices:
- "π Very Satisfied"
- "π Satisfied"
- "π Neutral"
- "π Dissatisfied"
- "π‘ Very Dissatisfied"
- id: "feedback"
type: "text"
message: "Any additional feedback?"
instruction: "Your thoughts help us improve"
- id: "recommend"
type: "confirm"
message: "Would you recommend us to others?"
default: true
output_mapping:
user:
name: "user_name"
satisfaction: "satisfaction"
feedback: "feedback"
would_recommend: "recommend"This creates an interactive form that looks like:
π User Satisfaction Survey
Quick survey to gather user feedback
ββββββββββββββββββββββββββββββββββββββββ
? What's your name? John Doe
? How satisfied are you with our service? π Satisfied
? Any additional feedback? Great service, very helpful!
? Would you recommend us to others? Yes
β
Flow execution completed!
Perfect for:
- π§ Application Configuration: Interactive setup wizards for complex applications
- π Deployment Workflows: Guided deployment configuration and environment setup
- π€ User Onboarding: Step-by-step user registration and profile creation
- π Surveys & Forms: Dynamic questionnaires with conditional logic
- π οΈ Development Tools: Interactive code generators and project scaffolding
- βοΈ System Administration: Server configuration and maintenance workflows
- π Data Collection: Research surveys and feedback collection
Create and edit forms interactively:
tui-designer designValidate form syntax and logic:
tui-designer validate # Validate all flows
tui-designer validate my_form.yml # Validate specific formTest forms with mock responses:
tui-designer test --flow user_survey
tui-designer test --flow user_survey --mock-data test_responses.jsonPreview form structure without execution:
tui-designer preview --list # List all forms
tui-designer preview --flow my_form # Preview specific form- id: "username"
type: "text"
message: "Enter username:"
validate: "required"
default: "user123"
instruction: "Must be unique"- id: "theme"
type: "select"
message: "Choose a theme:"
choices:
- "Light"
- "Dark"
- "Auto"
default: "Auto"- id: "features"
type: "multiselect"
message: "Select features to enable:"
choices:
- "Email notifications"
- "File attachments"
- "Advanced reporting"
- "API access"
defaults: ["Email notifications"]
instruction: "Use space to select, enter to confirm"- id: "agree_terms"
type: "confirm"
message: "Agree to terms?"
default: false
instruction: "Required to proceed"- id: "password"
type: "password"
message: "Enter password:"
validate: "password_length"
instruction: "At least 8 characters"- id: "welcome"
type: "info"
title: "Welcome to Setup"
message: |
This wizard will guide you through configuration.
All settings can be changed later if needed.
instruction: "Press Enter to continue"- id: "secret_key"
type: "computed"
compute: "discovered_data.environment.SECRET_KEY_BASE"
when: "secret_key_generation == false"
description: "Auto-generated from environment variables"Show/hide steps based on previous answers:
- id: "enable_email"
type: "confirm"
message: "Enable email notifications?"
- id: "smtp_host"
type: "text"
message: "SMTP host:"
condition: "enable_email == true" # Only show if email enabledBuilt-in validators for common patterns:
- id: "email"
type: "text"
message: "Email address:"
validate: "email" # Built-in email validation
error_message: "Please enter a valid email address"
- id: "port"
type: "text"
message: "Port number:"
validate: "integer" # Must be a valid integer
- id: "project_name"
type: "text"
message: "Project name:"
validate: "required" # Field cannot be empty
pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"
error_message: "Must start with letter, contain only letters, numbers, underscores, and hyphens"Available validators:
required- Field cannot be emptyemail- Valid email address formatdomain- Valid domain name formatinteger- Must be a valid integerpassword_length- Minimum password length (default 8 characters)
Enhanced choice definitions with labels and values:
- id: "smtp_port"
type: "select"
message: "SMTP port:"
choices:
- name: "587 (STARTTLS - Recommended)"
value: "587"
- name: "465 (SSL/TLS)"
value: "465"
- name: "25 (Unencrypted - Not recommended)"
value: "25"
default: "587"
instruction: "Choose based on your email provider's settings"Transform flat responses to structured data:
steps:
- id: "db_host"
type: "text"
message: "Database host:"
- id: "db_port"
type: "text"
message: "Database port:"
output_mapping:
database:
host: "db_host" # Nested structure
port: "db_port"
# Results in: {"database": {"host": "localhost", "port": "5432"}}Choose from built-in themes or create custom styling:
from tui_form_designer import FlowEngine
from questionary import Style
# Built-in themes
engine = FlowEngine(theme="dark") # dark, minimal, default
# Custom styling
custom_style = Style([
('question', 'bold cyan'),
('answer', 'bold green'),
('pointer', 'bold magenta')
])
engine = FlowEngine(style=custom_style)tui_layouts/
βββ basic/ # Simple example flows
β βββ simple_survey.yml
β βββ user_registration.yml
βββ advanced/ # Complex multi-step flows
β βββ application_setup.yml
β βββ docker_deployment.yml
βββ templates/ # Reusable flow templates
βββ openproject_main_config.yml
tui-designer test --interactiveCreate a JSON file with test responses:
{
"username": "testuser",
"email": "test@example.com",
"account_type": "Premium",
"agree_terms": true
}Then test with mocked responses:
tui-designer test --flow registration --mock-data test_responses.jsonAutomatically generate mock response templates:
# This creates registration_mock_template.json
tui-designer test
# Select "Generate mock template" optionAll step types support these common properties:
| Property | Required | Description | Example |
|---|---|---|---|
id |
β | Unique step identifier | "username" |
type |
β | Step type | "text", "select", etc. |
condition |
β | When to show this step | "enable_email == true" |
instruction |
β | Help text below question | "Must be unique" |
Required properties: id, type, message
- id: "project_name"
type: "text"
message: "Project name:"
default: "my-project" # Default value
instruction: "Used for containers" # Help text
validate: "required" # Validation rule
pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$" # Regex pattern
error_message: "Invalid format" # Custom error message
min_length: 3 # Minimum length
max_length: 50 # Maximum lengthRequired properties: id, type, message, choices
- id: "environment"
type: "select"
message: "Environment:"
choices:
- "Development"
- "Staging"
- "Production"
default: "Development"
instruction: "Choose deployment target"
# Advanced format with labels and values
- id: "database_port"
type: "select"
message: "Database port:"
choices:
- name: "5432 (PostgreSQL default)"
value: "5432"
- name: "3306 (MySQL default)"
value: "3306"
default: "5432"Required properties: id, type, message, choices
- id: "features"
type: "multiselect"
message: "Enable features:"
choices:
- "Email notifications"
- "File attachments"
- "API access"
- "Advanced reporting"
defaults: ["Email notifications"] # Pre-selected items
instruction: "Space to select, Enter to confirm"
min_selections: 1 # Minimum required
max_selections: 3 # Maximum allowedRequired properties: id, type, message
- id: "enable_ssl"
type: "confirm"
message: "Enable SSL?"
default: true # Default choice
instruction: "Recommended for production"Required properties: id, type, message
- id: "admin_password"
type: "password"
message: "Admin password:"
validate: "password_length" # Built-in validator
min_length: 8 # Minimum length
instruction: "At least 8 characters"
confirm: true # Ask for confirmationRequired properties: id, type
- id: "welcome_message"
type: "info"
title: "Welcome to Setup" # Header title
message: | # Multi-line message
This wizard will configure your application.
All settings can be changed later.
instruction: "Press Enter to continue"Required properties: id, type, compute
- id: "generated_secret"
type: "computed"
compute: "secrets.token_hex(32)" # Python expression
when: "manual_secret == false" # Condition for computation
description: "Auto-generated secret key"
# Using discovered data
- id: "detected_port"
type: "computed"
compute: "discovered_data.system.available_ports[0]"
fallback: "8080" # Default if computation fails| Validator | Description | Example |
|---|---|---|
required |
Field cannot be empty | validate: "required" |
email |
Valid email format | validate: "email" |
domain |
Valid domain name | validate: "domain" |
integer |
Must be integer | validate: "integer" |
password_length |
Min 8 characters | validate: "password_length" |
Show/hide steps based on previous answers:
# Simple condition
condition: "enable_email == true"
# Complex conditions
condition: "environment == 'Production' and ssl_enabled == true"
# Multiple value check
condition: "database_type in ['postgresql', 'mysql']"from tui_form_designer import FlowEngine
def setup_application():
engine = FlowEngine(flows_dir="config_tui_layouts")
config = engine.execute_flow("app_setup")
# Use the configuration
database_url = config['database']['url']
debug_mode = config['application']['debug']
return configimport questionary
from tui_form_designer import FlowEngine
def custom_validator(value):
if len(value) < 3:
raise questionary.ValidationError("Too short!")
return True
engine = FlowEngine()
engine.validators['custom'] = custom_validatorfrom tui_form_designer import FlowEngine, FlowValidationError, FlowExecutionError
try:
engine = FlowEngine()
results = engine.execute_flow("my_flow")
except FlowValidationError as e:
print(f"Flow validation failed: {e}")
except FlowExecutionError as e:
print(f"Flow execution failed: {e}")Default Theme (Blue/Orange):
engine = FlowEngine(theme="default")Dark Theme (Cyan/Green):
engine = FlowEngine(theme="dark") Minimal Theme (No colors):
engine = FlowEngine(theme="minimal")from questionary import Style
custom_style = Style([
('question', 'bold blue'),
('answer', 'fg:#ff9d00 bold'),
('pointer', 'fg:#673ab7 bold'),
('highlighted', 'fg:#673ab7 bold'),
('selected', 'fg:#cc5454'),
('instruction', 'italic'),
])
engine = FlowEngine(style=custom_style)The package includes several example flows:
simple_survey: Basic user satisfaction surveyuser_registration: Complete user account creationapplication_setup: Complex app configuration with database, email, etc.docker_deployment: Docker container configurationopenproject_main_config: Full OpenProject deployment setup
Try them out:
tui-designer demoContributions are welcome! Please feel free to submit issues, feature requests, or pull requests.
git clone https://github.com/JustinCBates/TUI_Form_Designer.git
cd TUI_Form_Designer
pip install -e .[dev]pytestblack src/ tests/
isort src/ tests/This project is licensed under the MIT License - see the LICENSE file for details.
- Built on the excellent Questionary library
- Originally developed as part of the OpenProject configuration management system
- Inspired by the need for better terminal user interfaces in DevOps and system administration tools
- Language: Python 3.8+
- Dependencies: Questionary, PyYAML, Pydantic
- UI Elements: 7 step types with advanced validation
- Validators: 5 built-in validators + custom support
- Size: Lightweight (~50KB)
- Type: CLI Tool + Python Library
- Status: Production Ready
Made with β€οΈ for the terminal UI community