Skip to main content
CLI Reference

travsr graph

Print a text representation of the graph around a file or symbol.

Synopsis

travsr graph <file-or-symbol> [flags]

Flags

FlagDefaultDescription
--depth <n>3BFS depth from the seed node
--direction <dir>bothdeps (dependencies) | callers | both
--format <fmt>treetree | dot | json
--all(none)Dump the entire graph (ignores --depth and --direction)

Examples

# Tree view of a file's neighbourhood
$ travsr graph src/auth/jwt.ts

src/auth/jwt.ts
├─ imports
│ ├─ src/config/env.ts
│ └─ node_modules/jsonwebtoken
├─ callers
│ ├─ src/middleware/auth.ts → verify()
│ ├─ src/routes/login.ts → sign()
│ └─ src/services/SessionService.ts → refresh()
└─ callees
├─ jsonwebtoken.sign()
└─ jsonwebtoken.verify()

# DOT format for Graphviz
$ travsr graph src/auth/jwt.ts --format dot | dot -Tsvg > jwt-graph.svg

# Callers only, depth 3
$ travsr graph UserService.find --direction callers --depth 3

# Full graph as JSON
$ travsr graph --all --format json > graph.json

DOT output example

digraph {
"src/auth/jwt.ts" -> "src/config/env.ts" [label="imports"]
"src/middleware/auth.ts" -> "src/auth/jwt.ts" [label="calls:verify"]
"src/routes/login.ts" -> "src/auth/jwt.ts" [label="calls:sign"]
}

Feed DOT output to Graphviz (dot, neato, fdp) for visual graph exploration.