CLI Reference
The FlowScope CLI analyzes SQL files from the command line, producing lineage in multiple output formats. It also includes a serve mode that runs an embedded web UI with file watching.
Installation
Section titled “Installation”# Using Cargocargo install flowscope-cli
# Or download from releases# https://github.com/pondpilot/flowscope/releasesBasic Usage
Section titled “Basic Usage”# Analyze a single fileflowscope query.sql
# Analyze multiple filesflowscope models/*.sql
# Read from stdincat query.sql | flowscopeecho "SELECT * FROM orders" | flowscopeOptions
Section titled “Options”Dialect Selection
Section titled “Dialect Selection”-d, --dialect <DIALECT>SQL dialect for parsing. Options: generic, ansi, postgresql, snowflake, bigquery, duckdb, redshift, mysql, mssql, sqlite, hive, databricks, clickhouse
flowscope -d snowflake warehouse/*.sqlflowscope --dialect bigquery analytics.sqlOutput Format
Section titled “Output Format”-f, --format <FORMAT>Output format. Options: table, json, mermaid, html, sql, csv, xlsx, duckdb
# Default: table formatflowscope query.sql
# JSON outputflowscope -f json query.sql > lineage.json
# Mermaid diagramflowscope -f mermaid query.sql > lineage.mmd
# Excel workbookflowscope -f xlsx -o report.xlsx queries/*.sql
# Interactive HTML reportflowscope -f html -o report.html query.sqlView Mode
Section titled “View Mode”-v, --view <VIEW>Lineage view mode. Options: table, column, script, hybrid
# Table-level lineage onlyflowscope -v table query.sql
# Column-level lineageflowscope -v column query.sql
# Script/file-level viewflowscope -v script models/*.sqlOutput File
Section titled “Output File”-o, --output <FILE>Write output to file instead of stdout.
flowscope -f json -o lineage.json query.sqlflowscope -f xlsx -o report.xlsx queries/*.sqlSchema Metadata
Section titled “Schema Metadata”-s, --schema <FILE>Provide DDL file for column resolution.
flowscope -s schema.sql -v column query.sqlLive Database Schema
Section titled “Live Database Schema”--metadata-url <URL>Fetch schema from a live database. Supports PostgreSQL, MySQL, and SQLite.
# PostgreSQLflowscope --metadata-url postgres://user:pass@localhost/db query.sql
# MySQLflowscope --metadata-url mysql://user:pass@localhost/db query.sql
# SQLiteflowscope --metadata-url sqlite:///path/to/database.db query.sqlTemplate Mode
Section titled “Template Mode”--template <MODE>Enable template preprocessing. Options: raw, jinja, dbt
flowscope --template dbt models/*.sqlTemplate Variables
Section titled “Template Variables”--template-var <KEY=VALUE>Set template variables for Jinja/dbt preprocessing.
flowscope --template dbt \ --template-var target_schema=production \ --template-var run_date=2024-01-01 \ models/*.sqlServe Mode
Section titled “Serve Mode”Run an embedded web UI with file watching:
flowscope --serve [OPTIONS] [PATH]Serve Options
Section titled “Serve Options”| Option | Description |
|---|---|
--port <PORT> | HTTP port (default: 8080) |
--watch <DIR> | Directory to watch for changes |
--open | Open browser automatically |
# Start server watching current directoryflowscope --serve --watch . --open
# Custom portflowscope --serve --port 3000 --watch ./sql
# Watch multiple directoriesflowscope --serve --watch models --watch macrosREST API Endpoints
Section titled “REST API Endpoints”When running in serve mode:
| Endpoint | Method | Description |
|---|---|---|
/api/health | GET | Health check with version |
/api/analyze | POST | Run lineage analysis |
/api/completion | POST | Code completion |
/api/split | POST | Split SQL into statements |
/api/files | GET | List watched files |
/api/schema | GET | Get schema metadata |
/api/export/:format | POST | Export to format |
/api/config | GET | Server configuration |
Output Formats
Section titled “Output Formats”Table Format (Default)
Section titled “Table Format (Default)”Human-readable table output:
┌─────────────────────────────────────────────────────────────┐│ Statement 1: SELECT │├─────────────────────────────────────────────────────────────┤│ Sources: orders, customers ││ Target: (query result) ││ ││ Column Lineage: ││ customer_name ← customers.name ││ total_amount ← SUM(orders.amount) │└─────────────────────────────────────────────────────────────┘JSON Format
Section titled “JSON Format”Structured JSON for programmatic use:
{ "statements": [ { "sql": "SELECT ...", "nodes": [...], "edges": [...], "issues": [] } ], "summary": { "tables": 2, "columns": 4, "edges": 6 }}Mermaid Format
Section titled “Mermaid Format”Diagram syntax for documentation:
graph LR orders[orders] customers[customers] output[Query Result] orders --> output customers --> outputHTML Format
Section titled “HTML Format”Self-contained HTML with interactive visualization. Includes the full React graph component.
CSV Format
Section titled “CSV Format”ZIP archive containing:
scripts.csv- SQL statementstables.csv- Tables and columnsedges.csv- Lineage relationshipsissues.csv- Validation issues
Excel Format
Section titled “Excel Format”Workbook with sheets for summary, lineage details, and issues.
SQL Format
Section titled “SQL Format”DuckDB-compatible DDL and INSERT statements for loading lineage into a database.
DuckDB Format
Section titled “DuckDB Format”Native DuckDB database file (requires native build, not WASM).
Examples
Section titled “Examples”Basic Analysis
Section titled “Basic Analysis”# Analyze and displayflowscope query.sql
# With column-level detailflowscope -v column query.sqlExport for Documentation
Section titled “Export for Documentation”# Mermaid for markdown docsflowscope -f mermaid -v table etl.sql > docs/lineage.mmd
# HTML report for sharingflowscope -f html -o lineage-report.html queries/*.sqldbt Project Analysis
Section titled “dbt Project Analysis”# Analyze dbt modelsflowscope --template dbt \ -d snowflake \ -v column \ models/**/*.sql
# With variablesflowscope --template dbt \ --template-var target_schema=analytics \ --template-var env=prod \ -f html -o lineage.html \ models/*.sqlCI/CD Integration
Section titled “CI/CD Integration”# JSON output for parsingflowscope -f json query.sql | jq '.summary'
# Check for issuesflowscope -f json query.sql | jq '.statements[].issues | length'Development Server
Section titled “Development Server”# Start development serverflowscope --serve --watch ./sql --port 8080 --open
# Server logs# Listening on http://localhost:8080# Watching: ./sql# Press Ctrl+C to stopExit Codes
Section titled “Exit Codes”| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Parse error or invalid input |
| 2 | File not found or I/O error |
| 3 | Invalid options |