mirror of
https://github.com/tldr-pages/tldr.git
synced 2026-08-28 11:25:16 +08:00
ast-grep: add page (#21517)
Co-authored-by: Dylan <145150333+dmmqz@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
# ast-grep
|
||||
|
||||
> Search, lint, and rewrite code using AST patterns.
|
||||
> More information: <https://ast-grep.github.io/reference/cli.html>.
|
||||
|
||||
- Search for a pattern in files:
|
||||
|
||||
`ast-grep run {{[-p|--pattern]}} '{{pattern}}' {{path/to/file}}`
|
||||
|
||||
- Search for a pattern in a specific language:
|
||||
|
||||
`ast-grep run {{[-p|--pattern]}} '{{pattern}}' {{[-l|--lang]}} {{python}} {{path/to/directory}}`
|
||||
|
||||
- Rewrite code matching a pattern:
|
||||
|
||||
`ast-grep run {{[-p|--pattern]}} '{{pattern}}' {{[-r|--rewrite]}} '{{replacement}}' {{path/to/file}}`
|
||||
|
||||
- Run rules from a configuration file:
|
||||
|
||||
`ast-grep scan {{[-r|--rule]}} {{path/to/rule.yml}} {{path/to/directory}}`
|
||||
|
||||
- Interactively search and rewrite code:
|
||||
|
||||
`ast-grep run {{[-p|--pattern]}} '{{pattern}}' {{[-i|--interactive]}} {{path/to/directory}}`
|
||||
|
||||
- Display help for a subcommand:
|
||||
|
||||
`ast-grep {{run}} {{[-h|--help]}}`
|
||||
Reference in New Issue
Block a user