Skip to content

Commit 8a6e891

Browse files
fix: udpate command name (ast-grep#626)
* 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
1 parent bef9280 commit 8a6e891

30 files changed

+121
-121
lines changed

website/advanced/custom-language.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ gcc -shared -fPIC -fno-exceptions -g -I 'src' -o mojo.so -O2 src/scanner.cc -xc
8686
## Register Language in `sgconfig.yml`
8787

8888
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.
9090

9191
You need to add a new entry under the `customLanguages` key with the name of your custom language and some properties:
9292

@@ -120,7 +120,7 @@ Now you are ready to use your custom language with ast-grep! You can use it as a
120120
For example, to search for all occurrences of `print` in mojo files, you can run:
121121

122122
```bash
123-
sg -p "print" -l mojo
123+
ast-grep -p "print" -l mojo
124124
```
125125

126126
Or you can write a rule in yaml like this:

website/advanced/faq.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ The encoding difference may cause different fallback parsing during [error recov
4646
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.
4747

4848
```sh
49-
sg run -p <PATTERN> --debug-query ast
49+
ast-grep run -p <PATTERN> --debug-query ast
5050
```
5151

5252
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`.

website/advanced/language-injection.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Let's start with a simple example of searching for JavaScript and CSS within HTM
2424
ast-grep has builtin support to search JavaScript and CSS inside HTML files.
2525

2626

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
2828

2929
Suppose we have an HTML file like below:
3030

@@ -43,7 +43,7 @@ Suppose we have an HTML file like below:
4343
Running this ast-grep command will extract the matching CSS style code out of the HTML file!
4444

4545
```sh
46-
sg run -p 'color: $COLOR'
46+
ast-grep run -p 'color: $COLOR'
4747
```
4848

4949
ast-grep outputs this beautiful CLI report.
@@ -55,7 +55,7 @@ test.html
5555
ast-grep works well even if just providing the pattern without specifying the pattern language!
5656

5757

58-
### **Using `sg scan`**: find JavaScript in HTML with rule files
58+
### **Using `ast-grep scan`**: find JavaScript in HTML with rule files
5959

6060
You can also use ast-grep's [rule file](https://ast-grep.github.io/guide/rule-config.html) to search injected languages.
6161

@@ -70,10 +70,10 @@ rule:
7070
message: Prefer use appropriate custom UI instead of obtrusive alert call.
7171
```
7272
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`.
7474

7575
```sh
76-
sg scan --rule no-alert.yml
76+
ast-grep scan --rule no-alert.yml
7777
```
7878

7979
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:
159159
You can search the CSS inside JavaScript in the project configuration folder using this command:
160160

161161
```sh
162-
sg -p 'background: $COLOR' -C 2
162+
ast-grep -p 'background: $COLOR' -C 2
163163
```
164164

165165
It will produce the match result:
@@ -223,7 +223,7 @@ const artistsQuery = graphql`
223223
We can search the GraphQL fragment via this `--inline-rules` scan.
224224

225225
```sh
226-
sg scan --inline-rules="{id: test, language: graphql, rule: {kind: fragment_spread}}"
226+
ast-grep scan --inline-rules="{id: test, language: graphql, rule: {kind: fragment_spread}}"
227227
```
228228

229229
Output

website/advanced/match-algorithm.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,12 @@ The table below summarize how nodes are skipped during matching.
129129

130130
ast-grep has two ways to configure pattern strictness.
131131

132-
1. Using `--strictness` in `sg run`
132+
1. Using `--strictness` in `ast-grep run`
133133

134-
You can use the `--strictness` flag in [`sg run`](/reference/cli/run.html)
134+
You can use the `--strictness` flag in [`ast-grep run`](/reference/cli/run.html)
135135

136136
```bash
137-
sg run -p '$FOO($BAR)' --strictness ast
137+
ast-grep run -p '$FOO($BAR)' --strictness ast
138138
```
139139

140140
2. Using `strictness` in Pattern Object

website/blog/migrate-bevy.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Before we start, we need to make sure that we have the following tools installed
4545
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).
4646

4747
```shell
48-
# install the binary `sg`/`ast-grep`
48+
# install the binary `ast-grep`
4949
cargo install ast-grep
5050
# or use brew
5151
brew install ast-grep
@@ -149,7 +149,7 @@ So we just need to change the import name. [Using ast-grep is trivial here](http
149149
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.
150150

151151
```
152-
sg -p 'CoreStage' -r CoreSet -i
152+
ast-grep -p 'CoreStage' -r CoreSet -i
153153
```
154154

155155
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):
183183
184184
The command:
185185
```bash
186-
sg -p 'StageLabel' -r SystemSet -i
186+
ast-grep -p 'StageLabel' -r SystemSet -i
187187
```
188188

189189
3. `SystemStage`
@@ -217,7 +217,7 @@ app.configure_set(
217217
Let's write a command for this code migration.
218218

219219
```bash
220-
sg \
220+
ast-grep \
221221
-p '$APP.add_stage_after($STAGE, $OWN_STAGE, SystemStage::parallel())' \
222222
-r '$APP.configure_set($OWN_STAGE.after($STAGE))' -i
223223
```
@@ -231,7 +231,7 @@ meta-variable is a wildcard expression that can match any single AST node. So we
231231
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.
232232

233233
```shell
234-
sg \
234+
ast-grep \
235235
-p 'app.add_stage_after($STAGE, $OWN_STAGE, SystemStage::parallel(),)' \
236236
-r 'app.configure_set($OWN_STAGE.after($STAGE))' -i
237237
```
@@ -267,7 +267,7 @@ app.add_system(my_system.in_base_set(CoreSet::PostUpdate))
267267
Let's also write a pattern for it.
268268

269269
```sh
270-
sg \
270+
ast-grep \
271271
-p '$APP.add_system_to_stage($STAGE, $SYS)' \
272272
-r '$APP.add_system($SYS.in_base_set($STAGE))' -i
273273
```
@@ -305,7 +305,7 @@ _It is still faster than me scratching my head about how to automate everything.
305305
Another change is to use `add_systems` instead of `add_system_set`. This is a simple pattern!
306306

307307
```sh
308-
sg \
308+
ast-grep \
309309
-p '$APP.add_system_set_to_stage($STAGE, $SYS,)' \
310310
-r '$APP.add_systems($SYS.in_set($STAGE))' -i
311311
```

website/blog/stars-3000.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ ast-grep is constantly evolving and improving thanks to the feedback and contrib
4747

4848
* 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.
4949
* 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.
5252
* ast-grep now prints matches with context like `grep -A -B -C`. See [issue](https://github.com/ast-grep/ast-grep/issues/464)
5353
* JSON schema is added for better YAML rule editing. See [folder](https://github.com/ast-grep/ast-grep/tree/main/schemas)
5454
* 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
6161
* 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)
6262
* Support global language config to let users specify default options for each language. See [issue](https://github.com/ast-grep/ast-grep/issues/658)
6363
* 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)
6565
* 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)
6666
* 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)
6767

website/blog/stars-5000.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ We have introduced a lot of new features in the past few months, and we want to
3939
### CLI
4040
* 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!
4141
* [`--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).
4343

4444
### Language Support
4545
* We have added support for three new languages: bash, php and elixir.

website/blog/stars-6000.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ The [ast-grep VSCode extension](https://marketplace.visualstudio.com/items?itemN
5555

5656
- **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.
5757
- **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`.
5959

6060
## Usability Improvements
6161

website/catalog/rule-template.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
language: JavaScript # please fully spell the language
33
playgroundLink: '[TODO]'
4-
command: 'sg -p [TODO] -r [TODO]'
4+
command: 'ast-grep -p [TODO] -r [TODO]'
55
hasFix: true
66
ruleType: 'pattern' # 'pattern' or 'yaml'
77
---
@@ -20,9 +20,9 @@ Some Description for your rule!
2020
### Pattern
2121

2222
```shell
23-
sg -p pattern -r rewrite -l js
23+
ast-grep -p pattern -r rewrite -l js
2424
# or without fixer
25-
sg -p pattern -l js
25+
ast-grep -p pattern -l js
2626
```
2727

2828
<!-- Use YAML in the example. Delete this section if use pattern. -->

website/catalog/rust/boshen-footgun.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Depending on your use case, you may want to use `char_indices()` instead of `cha
2323
### Pattern
2424

2525
```shell
26-
sg -p '$A.chars().enumerate()' \
26+
ast-grep -p '$A.chars().enumerate()' \
2727
-r '$A.char_indices()' \
2828
-l rs
2929
```

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy