You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* fix: udpate command name part 1
* fix: make wording less verbose
* fix: rename binary name
* fix: rename command name part 2
* fix: rename command part 3
* fix: rename command part 4
* fix: rename command name part 5
* fix: rename command name part 6
* fix: rename command name part 7
* fix: rename command part 8
* fix: rename command part 9
* fix: update command name part 10
* fix: update command name part 11
* fix: rename command part 12
* fix: fix link name
Once you have compiled the dynamic library for your custom language, you need to register it in the `sgconfig.yml` file.
89
-
You can use the command [`sg new`](/guide/scan-project.html#create-scaffolding) to create a project and find the configuration file in the project root.
89
+
You can use the command [`ast-grep new`](/guide/scan-project.html#create-scaffolding) to create a project and find the configuration file in the project root.
90
90
91
91
You need to add a new entry under the `customLanguages` key with the name of your custom language and some properties:
92
92
@@ -120,7 +120,7 @@ Now you are ready to use your custom language with ast-grep! You can use it as a
120
120
For example, to search for all occurrences of `print` in mojo files, you can run:
Copy file name to clipboardExpand all lines: website/advanced/faq.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,7 +46,7 @@ The encoding difference may cause different fallback parsing during [error recov
46
46
To debug the issue, you can use the [`--debug-query`](/reference/cli/run.html#debug-query-format) in the CLI to see the parsed AST nodes and meta variables.
47
47
48
48
```sh
49
-
sg run -p <PATTERN> --debug-query ast
49
+
ast-grep run -p <PATTERN> --debug-query ast
50
50
```
51
51
52
52
The debug output will show the parsed AST nodes and you can compare them with the [Playground](/playground.html). You can also use different debug formats like `cst` or `pattern`.
Copy file name to clipboardExpand all lines: website/advanced/language-injection.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,7 @@ Let's start with a simple example of searching for JavaScript and CSS within HTM
24
24
ast-grep has builtin support to search JavaScript and CSS inside HTML files.
25
25
26
26
27
-
### **Using `sg run`**: find patterns of CSS in an HTML file
27
+
### **Using `ast-grep run`**: find patterns of CSS in an HTML file
28
28
29
29
Suppose we have an HTML file like below:
30
30
@@ -43,7 +43,7 @@ Suppose we have an HTML file like below:
43
43
Running this ast-grep command will extract the matching CSS style code out of the HTML file!
44
44
45
45
```sh
46
-
sg run -p 'color: $COLOR'
46
+
ast-grep run -p 'color: $COLOR'
47
47
```
48
48
49
49
ast-grep outputs this beautiful CLI report.
@@ -55,7 +55,7 @@ test.html
55
55
ast-grep works well even if just providing the pattern without specifying the pattern language!
56
56
57
57
58
-
### **Using `sg scan`**: find JavaScript in HTML with rule files
58
+
### **Using `ast-grep scan`**: find JavaScript in HTML with rule files
59
59
60
60
You can also use ast-grep's [rule file](https://ast-grep.github.io/guide/rule-config.html) to search injected languages.
61
61
@@ -70,10 +70,10 @@ rule:
70
70
message: Prefer use appropriate custom UI instead of obtrusive alert call.
71
71
```
72
72
73
-
The rule above will detect usage of `alert` in JavaScript. Running the rule via `sg scan`.
73
+
The rule above will detect usage of `alert` in JavaScript. Running the rule via `ast-grep scan`.
74
74
75
75
```sh
76
-
sg scan --rule no-alert.yml
76
+
ast-grep scan --rule no-alert.yml
77
77
```
78
78
79
79
The command leverages built-in behaviors in ast-grep to handle language injection seamlessly. It will produce the following warning message for the HTML file above.
@@ -159,7 +159,7 @@ With the above `languageInjections` configuration, ast-grep will:
159
159
You can search the CSS inside JavaScript in the project configuration folder using this command:
160
160
161
161
```sh
162
-
sg -p 'background: $COLOR' -C 2
162
+
ast-grep -p 'background: $COLOR' -C 2
163
163
```
164
164
165
165
It will produce the match result:
@@ -223,7 +223,7 @@ const artistsQuery = graphql`
223
223
We can search the GraphQL fragment via this `--inline-rules` scan.
Copy file name to clipboardExpand all lines: website/blog/migrate-bevy.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -45,7 +45,7 @@ Before we start, we need to make sure that we have the following tools installed
45
45
Compared to the other two tools, ast-grep is lesser-known. In short it can do search and replace based on [abstract syntax trees](https://www.wikiwand.com/en/Abstract_syntax_tree). You can install it via [`cargo`](https://crates.io/crates/ast-grep) or [`brew`](https://formulae.brew.sh/formula/ast-grep).
46
46
47
47
```shell
48
-
# install the binary `sg`/`ast-grep`
48
+
# install the binary `ast-grep`
49
49
cargo install ast-grep
50
50
# or use brew
51
51
brew install ast-grep
@@ -149,7 +149,7 @@ So we just need to change the import name. [Using ast-grep is trivial here](http
149
149
We need to provide a pattern, `-p`, for it to search as well as a rewrite string, `-r` to replace the old API with the new one. The command should be quite self-explanatory.
150
150
151
151
```
152
-
sg -p 'CoreStage' -r CoreSet -i
152
+
ast-grep -p 'CoreStage' -r CoreSet -i
153
153
```
154
154
155
155
We suggest to add `-i` flag for `--interactive` editing. ast-grep will display the changed code diff and ask your decision to accept or not.
@@ -183,7 +183,7 @@ The [doc](https://bevyengine.org/learn/migration-guides/0.9-0.10/#label-types):
@@ -231,7 +231,7 @@ meta-variable is a wildcard expression that can match any single AST node. So we
231
231
However, I found some `add_stage_after`s are not replaced. Nah, ast-grep is [quite dumb](https://github.com/ast-grep/ast-grep/issues/374) that it cannot handle the optional comma after the last argument. So I used another query with a trailing comma.
Copy file name to clipboardExpand all lines: website/blog/stars-3000.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -47,8 +47,8 @@ ast-grep is constantly evolving and improving thanks to the feedback and contrib
47
47
48
48
* ast-grep’s YAML rule now has a new `transform` rule: `conversion`, which can change matches to different cases, such as upper, lower, or camelcase.
49
49
* ast-grep’s diff/rewriting now can fix multiple rules at once. See [commit](https://github.com/ast-grep/ast-grep/commit/2b301116996b7b010ed271672d35a3529fb36e56)
50
-
*`sg test -f`now accepts regex to selectively run ast-grep’s test case.
51
-
*`sg --json` supports multiple formats that powers [telescope-sg](https://github.com/Marskey/telescope-sg), a neovim plugin that integrates ast-grep with telescope.
50
+
*`ast-grep test -f`now accepts regex to selectively run ast-grep’s test case.
51
+
*`ast-grep --json` supports multiple formats that powers [telescope-sg](https://github.com/Marskey/telescope-sg), a neovim plugin that integrates ast-grep with telescope.
52
52
* ast-grep now prints matches with context like `grep -A -B -C`. See [issue](https://github.com/ast-grep/ast-grep/issues/464)
53
53
* JSON schema is added for better YAML rule editing. See [folder](https://github.com/ast-grep/ast-grep/tree/main/schemas)
54
54
* ast-grep now has official github action setup! See [action](https://github.com/ast-grep/action)
@@ -61,7 +61,7 @@ ast-grep has many plans and goals for the future to make it more useful and user
61
61
* Add python api support to allow users to write custom scripts using ast-grep. See [issue](https://github.com/ast-grep/ast-grep/issues/389)
62
62
* Support global language config to let users specify default options for each language. See [issue](https://github.com/ast-grep/ast-grep/issues/658)
63
63
* Improve napi documentation to help users understand how to use the native node module of ast-grep. See [issue](https://github.com/ast-grep/ast-grep/issues/682)
64
-
* Add metavar filter to make sg run more powerful by allowing users to filter matches based on metavariable values. See [issue](https://github.com/ast-grep/ast-grep/issues/379)
64
+
* Add metavar filter to make ast-grep run more powerful by allowing users to filter matches based on metavariable values. See [issue](https://github.com/ast-grep/ast-grep/issues/379)
65
65
* Add ast-grep’s pattern/rule tutorial to teach users how to write effective and efficient patterns and rules for ast-grep. See [issue](https://github.com/ast-grep/ast-grep.github.io/issues/154)
66
66
* Add examples to ast-grep’s reference page to illustrate the usage and functionality of each option and feature. See [issue](https://github.com/ast-grep/ast-grep.github.io/issues/266)
Copy file name to clipboardExpand all lines: website/blog/stars-5000.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,7 +39,7 @@ We have introduced a lot of new features in the past few months, and we want to
39
39
### CLI
40
40
* You can now use [`--inline-rules`](https://ast-grep.github.io/reference/cli/scan.html#inline-rules-rule-text) to run rules without creating any files on your disk! You can pass everything, pattern/rule/input, as a string. This is great for scripting!
41
41
*[`--stdin`](https://ast-grep.github.io/reference/cli/run.html#stdin) will always wait for your input so you can match some code written in your terminal.
42
-
* You can also select [custom languages](https://ast-grep.github.io/advanced/custom-language.html) in [`sg new`](https://ast-grep.github.io/reference/cli/new.html).
42
+
* You can also select [custom languages](https://ast-grep.github.io/advanced/custom-language.html) in [`ast-grep new`](https://ast-grep.github.io/reference/cli/new.html).
43
43
44
44
### Language Support
45
45
* We have added support for three new languages: bash, php and elixir.
Copy file name to clipboardExpand all lines: website/blog/stars-6000.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -55,7 +55,7 @@ The [ast-grep VSCode extension](https://marketplace.visualstudio.com/items?itemN
55
55
56
56
-**Tree-Sitter Version Bump**: We've upgraded to the latest tree-sitter version, enhancing parsing accuracy and speed. In future releases, we plan to leverage tree-sitter's [new Web Assembly grammar](https://zed.dev/blog/language-extensions-part-1) to support even more languages.
57
57
-**Scan and Diff Merge**: The [refactor](https://github.com/ast-grep/ast-grep/commit/c78299d2902662cd98bda44f3faf3fbc88439078) combines `CombinedScan::scan` and `CombinedScan::diff` for a more streamlined process.
58
-
-**Input Stream Optimization**: Now, ast-grep avoids unnecessary input stream usage when updating all rules [#943](https://github.com/ast-grep/ast-grep/pull/943), making it possible to use `sg scan --update-all`.
58
+
-**Input Stream Optimization**: Now, ast-grep avoids unnecessary input stream usage when updating all rules [#943](https://github.com/ast-grep/ast-grep/pull/943), making it possible to use `ast-grep scan --update-all`.
0 commit comments