CLI Reference
All flags and options for tsmetrics.
Synopsis
bash
tsmetrics analyze <PATH>... [OPTIONS]
Arguments
| Argument | Required | Description |
|---|---|---|
<PATH>... | Yes | One or more file paths or directories to analyze (recursive) |
Options
| Flag | Short | Default | Description |
|---|---|---|---|
--format <FORMAT> | -f | table | Output format: table, json, csv, html |
--exclude <PATTERN> | — | see below | Glob pattern(s) to exclude from analysis. Can be specified multiple times. |
--verbose | -v | off | Report skipped files to stderr |
--min-complexity <N> | — | none | Only show functions with CC ≥ N |
--min-loc <N> | — | none | Only show functions with LOC ≥ N |
--timing | — | off | Print elapsed time and thread count to stderr after analysis |
--version | — | — | Print version and exit |
--help | -h | — | Print help and exit |
Default exclusions
tsmetrics automatically skips these directories unless you explicitly pass them as a <PATH>:
default excluded paths
node_modules/ .git/ dist/ build/ coverage/ .next/
Use --exclude to add additional patterns on top of the defaults. To analyze a normally-excluded directory, pass it explicitly as a <PATH> argument.
Examples
bash
# Table output (default) tsmetrics analyze ./src # JSON output — pipe to jq for querying tsmetrics analyze ./src --format json | jq '.files[].functions[] | select(.cyclomatic_complexity > 10)' # CSV output — import into spreadsheet tsmetrics analyze ./src --format csv > metrics.csv # Self-contained HTML report tsmetrics analyze ./src --format html > report.html # Exclude test files and generated code tsmetrics analyze ./src --exclude "**/*.test.ts" --exclude "**/*.generated.ts" # Filter to complex functions only tsmetrics analyze ./src --min-complexity 10 # Show timing info tsmetrics analyze ./src --timing # Verbose — see skipped files tsmetrics analyze ./src --verbose 2>&1 | grep SKIP
Exit codes
| Code | Meaning |
|---|---|
0 | Success |
1 | Error (parse failure, invalid config, etc.) |
Note: When using
Edit on GitHub
--min-complexity or --min-loc, the summary counts (files, functions) reflect only the filtered results, not the total analyzed.