CSLCLI Examples
Basic Usage
Validate a Script
Check if a CSL script is valid:
If valid, outputs the parsed script. If invalid, shows errors.
Verbose Mode
Get detailed parsing information:
Output:
Error Handling
Syntax Errors
Example with syntax error:
$ cslcli broken_script.csl
Error parsing broken_script.csl at line 5, column 10:
|
5 | WAIT 10x
| ^ invalid character in number
|
Expected: valid number
Missing Files
Scripting Integration
Build Validation
Include CSL validation in build scripts:
#!/bin/bash
# Validate all CSL test scripts
for script in tests/*.csl; do
echo "Validating $script..."
if cslcli "$script" > /dev/null; then
echo " ✓ OK"
else
echo " ✗ FAILED"
exit 1
fi
done
echo "All scripts valid!"
CI/CD Pipeline
# Example GitHub Actions workflow
- name: Validate CSL Scripts
run: |
for script in scripts/**/*.csl; do
cslcli "$script"
done
Development Workflow
Test Script Development
Iterative development with immediate feedback:
# Edit script
vi game_test.csl
# Validate
cslcli game_test.csl
# If errors, fix and repeat
# Once valid, use in automation
Converting Scripts
Normalize/format CSL scripts:
Common CSL Patterns
Example Valid Script
# Load program
LOAD "game.dsk"
# Wait for loading
WAIT 3000
# Send keypress
KEYPRESS SPACE
# Wait and verify
WAIT 1000
CHECK SCREEN "GAME OVER"
Validation Commands
# Quick syntax check
cslcli test.csl > /dev/null && echo "Valid" || echo "Invalid"
# Count instructions
cslcli -v test.csl 2>&1 | grep "parsed" | awk '{print $3}'
Tips
- Use
-vduring development for detailed feedback - Keep scripts in version control
- Validate scripts in CI/CD pipelines
- Use meaningful comments in CSLfiles
- Test scripts incrementally
- Pipe output to files for formatted versions