sg
Ast-grep is a tool for code structural search, lint, and rewriting. More information: https://ast-grep.github.io/guide/introduction.html.
- Scan for possible queries using interactive mode:
sg scan --interactive
- Rewrite code in the current directory using patterns:
sg run --pattern '' --rewrite '' --lang
- Visualize possible changes without applying them:
sg run --pattern '' --rewrite '' --lang
- Output results as JSON, extract information using
jq, and interactively view it usingjless:
sg run --pattern '' --rewrite '' --json | jq '' | jless
来源:tldr-pages contributors · 作者与贡献记录 · CC BY 4.0。离线整理了版式、链接和媒体显示。
