Skip to content

Commit

Permalink
doc: add doc for --follow
Browse files Browse the repository at this point in the history
  • Loading branch information
HerringtonDarkholme committed Sep 14, 2024
1 parent 057b57f commit d5ec1f6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions website/reference/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@ sg run [OPTIONS] --pattern <PATTERN> [PATHS]...
| Short | Long | Description |
|-------|------|-------------|
| -p| --pattern `<PATTERN>` | AST pattern to match. |
| | --selector `<KIND>` | AST kind to extract sub-part of pattern to match. |
| -r| --rewrite `<REWRITE>` | String to replace the matched AST node. |
| -l| --lang `<LANG>` | The language of the pattern query. ast-grep will infer the language based on file extension if this option is omitted. |
| | --debug-query`[=<format>]` | Print query pattern's tree-sitter AST. Requires lang be set explicitly. |
| | --strictness `<STRICTNESS>` | The strictness of the pattern [possible values: cst, smart, ast, relaxed, signature] |
| | --follow | Follow symbolic links |
| -i| --interactive | Start interactive edit session. Code rewrite only happens inside a session. |
| -U| --update-all | Apply all rewrite without confirmation if true. |
| | --json`[=<style>]` | Output matches in structured JSON [possible values: pretty, stream, compact] |
Expand Down Expand Up @@ -59,6 +62,7 @@ sg scan [OPTIONS] [PATHS]...
| -i | --interactive|Start interactive edit session.|
| | --color `<WHEN>`|Controls output color [default: auto] [possible values: auto, always, ansi, never]|
| | --report-style `<REPORT_STYLE>` | [default: rich] [possible values: rich, medium, short]
| | --follow | Follow symbolic links |
| | --json`[=<style>]` | Output matches in structured JSON [possible values: pretty, stream, compact] |
| | --format `<FORMAT>` | Output warning/error messages in GitHub Action format [possible values: github] |
| -U | --update-all | Apply all rewrite without confirmation |
Expand Down
12 changes: 12 additions & 0 deletions website/reference/cli/run.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ Possible values:
- **cst**: Print the query in tree-sitter CST format, both named and unnamed nodes are shown
- **sexp**: Print the query in S-expression format

#### `--selector <KIND>`

AST kind to extract sub-part of pattern to match.

selector defines the sub-syntax node kind that is the actual matcher of the pattern. See https://ast-grep.github.io/guide/rule-config/atomic-rule.html#pattern-object.

### `--strictness <STRICTNESS>`

The strictness of the pattern. More strict algorithm will match less code. See [match algorithm deep dive](/advanced/match-algorithm.html) for more details.
Expand Down Expand Up @@ -81,6 +87,12 @@ Enable search code from StdIn.

Use this if you need to take code stream from standard input.

### `--follow`

Follow symbolic links.

This flag instructs ast-grep to follow symbolic links while traversing directories. This behavior is disabled by default. Note that ast-grep will check for symbolic link loops and report errors if it finds one. ast-grep will also report errors for broken links.

## Output Options

### `-i, --interactive`
Expand Down
6 changes: 6 additions & 0 deletions website/reference/cli/scan.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ Enable search code from StdIn.

Use this if you need to take code stream from standard input.

### `--follow`

Follow symbolic links.

This flag instructs ast-grep to follow symbolic links while traversing directories. This behavior is disabled by default. Note that ast-grep will check for symbolic link loops and report errors if it finds one. ast-grep will also report errors for broken links.

## Output Options

### `-i, --interactive`
Expand Down

0 comments on commit d5ec1f6

Please sign in to comment.