TauQ Query
A programmable pre-processor for generating Tauq notation dynamically.
See TQQ in Action
Watch how each directive transforms into output
Drag the slider to scrub through steps, or Play to animate. Try each example to see different TQQ directives in action.
On This Page
Directives Overview
All TQQ directives start with ! and are processed top-to-bottom. Non-directive lines pass through unchanged.
All Directives at a Glance
| Directive | Purpose | Output |
|---|---|---|
!set KEY value | Set environment variable | None (side effect) |
!emit command | Run command, insert stdout | Command's stdout |
!run interp {...} | Run inline script block | Script's stdout |
!pipe command | Transform accumulated output | Transformed content |
!import file.tqn | Include and process file | File's processed content |
!json file.json | Convert JSON to Tauq | Tauq notation |
!read file.txt | Read file as string | Quoted string |
Variables & Emit
Use !set to define variables and !emit to run commands. Variables are passed as environment variables to child processes.
Basic Usage
# Set variables for child processes
!set APP_NAME "MyService"
!set VERSION "2.0.0"
!set ENV "production"
# Emit command output as Tauq
!emit sh -c 'echo "build_date \"$(date +%Y-%m-%d)\""'
!emit sh -c 'echo "hostname \"$(hostname)\""'
# Static content passes through as-is
config {
name MyService
version "2.0.0"
} Key point: The output of !emit must be valid Tauq syntax.
The command's stdout is inserted directly into the output stream.
⚠ Important: Output Must Be Valid Tauq
Whatever your commands output will be parsed as Tauq notation. If you emit invalid syntax, the final parse will fail. Always ensure commands output properly formatted key-value pairs, arrays, or objects.
Inline Scripts (!run)
For complex logic, embed a script block. The script's stdout becomes part of the output.
Python Script
!run python3 {
import json
import random
# Generate random user data
users = [
{"id": i, "score": random.randint(1, 100)}
for i in range(5)
]
print(json.dumps(users))
} Outputs JSON array, which Tauq can parse directly
Shell Script
!run sh {
echo "host \"$(hostname)\""
echo "user \"$(whoami)\""
echo "date \"$(date +%Y-%m-%d)\""
} Outputs Tauq key-value pairs
Supported Interpreters
Any interpreter available on your system works with !run:
Data Pipelines (!pipe)
The !pipe directive is the most powerful feature. It takes all accumulated output and transforms it through a command.
Example: Sorting Data
# Player scores as key-value pairs
Alice 50
Bob 20
Carol 95
Dave 75
# Sort by score (2nd column), descending
!pipe sort -k 2 -nr Carol 95
Dave 75
Alice 50
Bob 20 ⚠ !pipe Transforms All Previous Output
When TQQ encounters !pipe, it:
- Takes all accumulated output so far (everything above the !pipe)
- Sends it as stdin to the command
- Replaces the accumulated output with the command's stdout
This means !pipe should be placed at the end of your data. Content after !pipe won't be piped.
Example: Filtering Data
# Filter and transform user data
!def User id name role
!use User
101 "Alice" "Dev"
102 "Bob" "Ops"
103 "Carol" "Design"
# Keep only Dev and Ops roles
!pipe grep -E "Dev|Ops" Result: Only rows matching "Dev" or "Ops" are kept. The schema definitions are preserved in the output.
File Operations
Import files, convert JSON, and read raw content into your data stream.
!import - Include Tauq Files
Recursively process and insert another file:
!import ./common/schemas.tqn
!import ./config/defaults.tqn
# Your local content here
app_name "MyService" !json - Convert JSON to Tauq
Read a JSON file and convert it to Tauq notation on the fly:
# users.json contains: [{"id": 1, "name": "Alice"}, ...]
!json ./data/users.json
# Becomes:
# [{ id 1 name Alice } { id 2 name Bob }] !read - Embed Raw Text
Read a file and emit it as a quoted string (useful for templates):
template !read ./templates/email.html
# Becomes:
# template "<html>...entire file contents...</html>" Real-World Examples
Dynamic Build Configuration
Generate config with build metadata:
# main.tqq - Production config
!set ENV "production"
# Import shared definitions
!import ./schemas.tqn
!import ./defaults.tqn
# Import JSON and convert to Tauq
!json ./data/users.json
# Emit computed values
!emit sh -c 'echo "generated_at \"$(date -Iseconds)\""' Environment-Aware Config
Generate different configs based on environment:
# Environment-aware configuration
!set ENV "production"
!run python3 {
import os
env = os.environ.get('ENV', 'development')
if env == 'production':
print('database { host "db.prod.example.com" pool_size 20 }')
else:
print('database { host "localhost" pool_size 5 }')
} File System Inventory
Generate structured data from directory listing:
# Generate file listing as Tauq records
!def File name size modified
!use File
!emit ls -la *.rs | tail -n +2 | awk '{print "\"" $9 "\" " $5 " \"" $6 " " $7 " " $8 "\""}' Best Practices
✓ Do
- Validate command output is valid Tauq
- Use
!setfor repeated values - Keep
!pipeat the end of sections - Test .tqq files with
tauq build - Use
!importfor shared schemas
✗ Don't
- Emit unquoted strings with spaces
- Put content after
!pipe(it won't be piped) - Rely on commands that aren't portable
- Forget to escape quotes in emit/run output
- Output invalid Tauq syntax from commands
CLI Usage
Process .tqq files with the Tauq CLI:
# Process TQQ and output Tauq notation
tauq build input.tqq -o output.tqn
# Process TQQ and convert directly to JSON
tauq build input.tqq --json -o output.json
# Validate TQQ without writing output
tauq validate input.tqq Ready to Build Data Pipelines?
TQQ transforms static data files into dynamic, programmable content. Combine it with Tauq's token efficiency for powerful data workflows.