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

website/catalog/rust/get-digit-count-in-usize.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ The snippet above computes the integer logarithm base 10 of the number and adds
1919
### Pattern
2020

2121
```shell
22-
sg -p '$NUM.to_string().chars().count()' \
22+
ast-grep -p '$NUM.to_string().chars().count()' \
2323
-r '$NUM.checked_ilog10().unwrap_or(0) + 1' \
2424
-l rs
2525
```

website/catalog/typescript/redundant-usestate-type.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ We can usually skip annotating if the generic type argument is a single primitiv
1313

1414
::: code-group
1515
```bash [number]
16-
sg -p 'useState<number>($A)' -r 'useState($A)' -l ts
16+
ast-grep -p 'useState<number>($A)' -r 'useState($A)' -l ts
1717
```
1818

1919
```bash [string]
20-
sg -p 'useState<string>($A)' -r 'useState($A)'
20+
ast-grep -p 'useState<string>($A)' -r 'useState($A)'
2121
```
2222

2323
```bash [boolean]
24-
sg -p 'useState<boolean>($A)' -r 'useState($A)'
24+
ast-grep -p 'useState<boolean>($A)' -r 'useState($A)'
2525
```
2626
:::
2727

website/guide/introduction.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ ast-grep is a new AST based tool for managing your code, at massive scale.
1515
Using ast-grep can be as simple as running a single command in your terminal:
1616

1717
```bash
18-
sg --pattern 'var code = $PAT' --rewrite 'let code = $PAT' --lang js
18+
ast-grep --pattern 'var code = $PAT' --rewrite 'let code = $PAT' --lang js
1919
```
2020

2121
The command above will replace `var` statement with `let` for all <abbr title="ast-grep will also infer the language if you omit --lang">JavaScript</abbr> files.
@@ -24,7 +24,7 @@ The command above will replace `var` statement with `let` for all <abbr title="a
2424

2525
ast-grep is a versatile tool for searching, linting and rewriting code in various languages.
2626

27-
* **Search**: As a command line tool in your terminal, ast-grep, `sg`, can precisely search code based on AST, running through ten thousand files in sub seconds.
27+
* **Search**: As a command line tool in your terminal, `ast-grep` can precisely search code based on AST, running through ten thousand files in sub seconds.
2828
* **Lint**: You can also use ast-grep as a linter. Thanks to the flexible rule configuration, adding a new customized rule is more intuitive and straightforward. It also has a pretty error reporting out of box
2929
* **Rewrite**: ast-grep provide jQuery like utility methods to traverse and manipulate syntax tree. Besides, you can also use operators to compose complex matching from simple patterns.
3030

@@ -71,7 +71,7 @@ Consider it as same as `grep` but based on AST instead of text.
7171
In comparison to Babel, we can complete this hello-world task in ast-grep trivially
7272

7373
```bash
74-
sg -p "console.log"
74+
ast-grep -p "console.log"
7575
```
7676

7777
See [playground](/playground.html) in action!

website/guide/project/lint-rule.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,5 +191,5 @@ After you have written your rule, you can test it with ast-grep's builtin `test`
191191
Let's see it in [next section](/guide/test-rule).
192192

193193
:::tip Pro Tip
194-
You can write a standalone [rule file](/reference/rule.html) and the command `sg scan -r rule.yml` to perform an [ad-hoc search](/guide/tooling-overview.html#run-one-single-query-or-one-single-rule).
194+
You can write a standalone [rule file](/reference/rule.html) and the command `ast-grep scan -r rule.yml` to perform an [ad-hoc search](/guide/tooling-overview.html#run-one-single-query-or-one-single-rule).
195195
:::

website/guide/project/project-config.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Root Configuration File
44

55
ast-grep supports using [YAML](https://yaml.org/) to configure its linting rules to scan your code repository.
6-
We need a root configuration file `sgconfig.yml` to specify directories where `sg` can find all rules.
6+
We need a root configuration file `sgconfig.yml` to specify directories where `ast-grep` can find all rules.
77

88
In your project root, add `sgconfig.yml` with content as below.
99

@@ -28,10 +28,10 @@ my-awesome-project
2828
|- not-a-rule.yml
2929
```
3030
31-
All the YAML files under `rules` folder will be treated as rule files by `sg`, while`not-a-rule.yml` is ignored by ast-grep.
31+
All the YAML files under `rules` folder will be treated as rule files by `ast-grep`, while`not-a-rule.yml` is ignored.
3232
3333
34-
**Note, the [`sg scan`](/reference/cli.html#scan) command requires you have an `sgconfig.yml` in your project root.**
34+
**Note, the [`ast-grep scan`](/reference/cli.html#scan) command requires you have an `sgconfig.yml` in your project root.**
3535
3636
:::tip Pro tip
3737
We can also use directories in `node_modules` to reuse preconfigured rules published on npm!

website/guide/quick-start.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,18 @@ pip install ast-grep-cli
4545
```
4646
:::
4747

48-
The binary command, `sg`, or `ast-grep`, should be available now. Let's try it with `--help`.
48+
The binary command, `ast-grep` or `sg`, should be available now. Let's try it with `--help`.
4949

5050
```shell
51-
sg --help
52-
# if you are on Linux
5351
ast-grep --help
52+
# if you are not on Linux
53+
sg --help
5454
```
5555

5656
:::danger Use `sg` on Linux
5757
Linux has a default command `sg` for `setgroups`. You can use the full command name `ast-grep` instead of `sg`.
5858
You can also use shorter alias if you want by `alias sg=ast-grep`.
59-
We will use `sg` in the guide below.
59+
We will use `ast-grep` in the guide below.
6060
:::
6161

6262

@@ -103,22 +103,22 @@ Optionally, we can use `lang` to tell ast-grep our target code language.
103103

104104
:::code-group
105105
```shell [Full Command]
106-
sg --pattern '$PROP && $PROP()' --lang ts TypeScript/src
106+
ast-grep --pattern '$PROP && $PROP()' --lang ts TypeScript/src
107107
```
108108
```shell [Short Form]
109-
sg -p '$PROP && $PROP()' -l ts TypeScript/src
109+
ast-grep -p '$PROP && $PROP()' -l ts TypeScript/src
110110
```
111111
```shell [Without Lang]
112112
# ast-grep will infer languages based on file extensions
113-
sg -p '$PROP && $PROP()' TypeScript/src
113+
ast-grep -p '$PROP && $PROP()' TypeScript/src
114114
```
115115
:::
116116

117117
:::tip Pro Tip
118118
Pattern must be quoted by single quote `'` to prevent shell from interpreting `$` sign.
119-
`sg -p '$PROP && $PROP()'` is okay.
119+
`ast-grep -p '$PROP && $PROP()'` is okay.
120120

121-
But `sg -p "$PROP && $PROP()"` will be interpreted as `sg -p " && ()"` after shell expansion.
121+
But `ast-grep -p "$PROP && $PROP()"` will be interpreted as `ast-grep -p " && ()"` after shell expansion.
122122
:::
123123

124124
## Rewrite
@@ -127,7 +127,7 @@ Cool? Now we can use this pattern to refactor TypeScript source!
127127

128128
```shell
129129
# pattern and language argument support short form
130-
sg -p '$PROP && $PROP()' \
130+
ast-grep -p '$PROP && $PROP()' \
131131
--rewrite '$PROP?.()' \
132132
--interactive \
133133
-l ts \

0 commit comments

Comments
 (0)