@@ -45,18 +45,18 @@ pip install ast-grep-cli
45
45
```
46
46
:::
47
47
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 ` .
49
49
50
50
``` shell
51
- sg --help
52
- # if you are on Linux
53
51
ast-grep --help
52
+ # if you are not on Linux
53
+ sg --help
54
54
```
55
55
56
56
:::danger Use ` sg ` on Linux
57
57
Linux has a default command ` sg ` for ` setgroups ` . You can use the full command name ` ast-grep ` instead of ` sg ` .
58
58
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.
60
60
:::
61
61
62
62
@@ -103,22 +103,22 @@ Optionally, we can use `lang` to tell ast-grep our target code language.
103
103
104
104
::: code-group
105
105
``` shell [Full Command]
106
- sg --pattern ' $PROP && $PROP()' --lang ts TypeScript/src
106
+ ast-grep --pattern ' $PROP && $PROP()' --lang ts TypeScript/src
107
107
```
108
108
``` shell [Short Form]
109
- sg -p ' $PROP && $PROP()' -l ts TypeScript/src
109
+ ast-grep -p ' $PROP && $PROP()' -l ts TypeScript/src
110
110
```
111
111
``` shell [Without Lang]
112
112
# ast-grep will infer languages based on file extensions
113
- sg -p ' $PROP && $PROP()' TypeScript/src
113
+ ast-grep -p ' $PROP && $PROP()' TypeScript/src
114
114
```
115
115
:::
116
116
117
117
:::tip Pro Tip
118
118
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.
120
120
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.
122
122
:::
123
123
124
124
## Rewrite
@@ -127,7 +127,7 @@ Cool? Now we can use this pattern to refactor TypeScript source!
127
127
128
128
``` shell
129
129
# pattern and language argument support short form
130
- sg -p ' $PROP && $PROP()' \
130
+ ast-grep -p ' $PROP && $PROP()' \
131
131
--rewrite ' $PROP?.()' \
132
132
--interactive \
133
133
-l ts \
0 commit comments