Skip to content

Commit 26e8157

Browse files
doc: add docs for new options
1 parent a5d5549 commit 26e8157

File tree

3 files changed

+50
-3
lines changed

3 files changed

+50
-3
lines changed

website/reference/cli.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,15 @@ sg run [OPTIONS] --pattern <PATTERN> [PATHS]...
2727
| | --debug-query`[=<format>]` | Print query pattern's tree-sitter AST. Requires lang be set explicitly. |
2828
| | --strictness `<STRICTNESS>` | The strictness of the pattern [possible values: cst, smart, ast, relaxed, signature] |
2929
| | --follow | Follow symbolic links |
30+
| | --no-ignore `<NO_IGNORE>` | Do not respect hidden file system or ignore files (.gitignore, .ignore, etc.) [possible values: hidden, dot, exclude, global, parent, vcs] |
31+
| | --stdin | Enable search code from StdIn. See [link](/guide/tooling-overview.html#enable-stdin-mode) |
32+
| | --globs `<GLOBS>` | Include or exclude file paths
3033
| -i| --interactive | Start interactive edit session. Code rewrite only happens inside a session. |
3134
| -U| --update-all | Apply all rewrite without confirmation if true. |
3235
| | --json`[=<style>]` | Output matches in structured JSON [possible values: pretty, stream, compact] |
33-
| | --heading `<WHEN>` | Controls whether to print the file name as heading [default: auto] [possible values: auto, always, never] |
3436
| | --color `<WHEN>` | Controls output color [default: auto] |
35-
| | --no-ignore `<NO_IGNORE>` | Do not respect hidden file system or ignore files (.gitignore, .ignore, etc.) [possible values: hidden, dot, exclude, global, parent, vcs] |
36-
| | --stdin | Enable search code from StdIn. See [link](/guide/tooling-overview.html#enable-stdin-mode) |
37+
| | --tracing `<LEVEL>` | Show tracing information for file/rule discovery and scanning [default: nothing] [possible values: nothing, summary]
38+
| | --heading `<WHEN>` | Controls whether to print the file name as heading [default: auto] [possible values: auto, always, never] |
3739
| -A| --after `<NUM>` | Show NUM lines after each match [default: 0] |
3840
| -B| --before `<NUM>` | Show NUM lines before each match [default: 0] |
3941
| -C| --context `<NUM>` | Show NUM lines around each match [default: 0] |
@@ -68,6 +70,8 @@ sg scan [OPTIONS] [PATHS]...
6870
| -U | --update-all | Apply all rewrite without confirmation |
6971
| | --no-ignore `<NO_IGNORE>` | Do not respect ignore files. (.gitignore, .ignore, etc.) [possible values: hidden, dot, exclude, global, parent, vcs] |
7072
| | --stdin | Enable search code from StdIn. See [link](/guide/tooling-overview.html#enable-stdin-mode) |
73+
| | --globs `<GLOBS>` | Include or exclude file paths
74+
| | --tracing `<LEVEL>` | Show tracing information for file/rule discovery and scanning [default: nothing] [possible values: nothing, summary]
7175
| -h| --help|Print help|
7276

7377
## `sg test`
@@ -135,6 +139,13 @@ Start a language server to [report diagnostics](/guide/scan-project.html) in you
135139
sg lsp
136140
```
137141

142+
### Options
143+
144+
| Short | Long | Description |
145+
|-------|------|-------------|
146+
| -c | --config `<CONFIG_FILE>`| Path to ast-grep root config, default is `sgconfig.yml` |
147+
| -h| `--help` | Print help (see more with '--help') |
148+
138149
## `sg completions`
139150

140151
Generate shell completion script.

website/reference/cli/run.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ Enable search code from StdIn.
8787

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

90+
### `--globs <GLOBS>`
91+
92+
Include or exclude file paths.
93+
94+
Include or exclude files and directories for searching that match the given glob. This always overrides any other ignore logic. Multiple glob flags may be used. Globbing rules match .gitignore globs. Precede a glob with a `!` to exclude it. If multiple globs match a file or directory, the glob given later in the command line takes precedence.
95+
9096
### `--follow`
9197

9298
Follow symbolic links.
@@ -141,6 +147,18 @@ Possible values:
141147
- **always**: Always print heading regardless of output type
142148
- **never**: Never print heading regardless of output type
143149

150+
### `--tracing <LEVEL>`
151+
152+
Show tracing information for file/rule discovery and scanning.
153+
154+
This flag helps user to inspect ast-grep's internal filtering of files and rules. tracing will output how many and why files and rules are scanned and skipped. tracing information outputs to stderr and does not affect the result of the search.
155+
156+
[default: nothing]
157+
158+
Possible values:
159+
- **nothing**: Do not show any tracing information
160+
- **summary**: Show summary about how many files are scanned and skipped
161+
144162
## Context Options
145163

146164
### `-A, --after <NUM>`

website/reference/cli/scan.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ Follow symbolic links.
6767

6868
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.
6969

70+
### `--globs <GLOBS>`
71+
72+
Include or exclude file paths.
73+
74+
Include or exclude files and directories for searching that match the given glob. This always overrides any other ignore logic. Multiple glob flags may be used. Globbing rules match .gitignore globs. Precede a glob with a `!` to exclude it. If multiple globs match a file or directory, the glob given later in the command line takes precedence.
75+
7076
## Output Options
7177

7278
### `-i, --interactive`
@@ -88,6 +94,18 @@ Possible values:
8894
- stream: Prints each match as a separate JSON object, followed by a newline character. This is useful for streaming the output to other programs that can read one object per line
8995
- compact: Prints the matches as a single-line JSON array, without any whitespace. This is useful for saving space and minimizing the output size
9096

97+
### `--tracing <LEVEL>`
98+
99+
Show tracing information for file/rule discovery and scanning.
100+
101+
This flag helps user to inspect ast-grep's internal filtering of files and rules. tracing will output how many and why files and rules are scanned and skipped. tracing information outputs to stderr and does not affect the result of the search.
102+
103+
[default: nothing]
104+
105+
Possible values:
106+
- **nothing**: Do not show any tracing information
107+
- **summary**: Show summary about how many files are scanned and skipped
108+
91109
### `--format <FORMAT>`
92110
Output warning/error messages in GitHub Action format.
93111

0 commit comments

Comments
 (0)