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
Copy file name to clipboardExpand all lines: README.md
+16-7Lines changed: 16 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,8 @@ Patcher based on rules. Written for [Deployer](https://github.com/impulse-sw/dep
4
4
5
5
Features:
6
6
7
-
- script support (Python, Lua, Rhai) - to find, replace, or decode/encode
7
+
- embedded script support (Lua, Rhai) - to find, replace, or decode/encode
8
+
- any shell command support - to find, replace, or decode/encode
8
9
- regexes
9
10
10
11
## Build
@@ -38,7 +39,7 @@ Also you can use `smart-patcher` as library and even specify needed features:
38
39
39
40
```toml
40
41
[dependencies]
41
-
smart-patcher = { version = "0.3.0", default-features = false, features = ["python", "lua", "rhai"] }
42
+
smart-patcher = { version = "0.4", features = ["lua", "rhai"] }
42
43
```
43
44
44
45
## Patches
@@ -92,7 +93,7 @@ There are several rule types to cut text sections step by step:
92
93
2.`not_contains` - nearly the same
93
94
3.`before` and `after` - cuts the patchable area before and after specified regular expression matches
94
95
4.`cursor_at_begin` and `cursor_at_end` - moves the `inplace` cursor at begin or at end of the text area
95
-
5.`find_by_{lua,python,rhai}` - cuts the section by Lua/Python/Rhai script
96
+
5.`find_by_{lua,sh,rhai}` - cuts the section by Lua/Rhai or shell script
96
97
97
98
This is how a step by step set looks like:
98
99
@@ -109,7 +110,7 @@ This is how a step by step set looks like:
109
110
"after": "...but after this."
110
111
},
111
112
{
112
-
"find_by_python": "some_script_afterall.py"
113
+
"find_by_sh": "some_script_afterall.py"
113
114
}
114
115
]
115
116
}
@@ -152,12 +153,20 @@ See the `tests/test_v5.py` example (and `tests/test_v5.docx` file). This is simp
152
153
```json
153
154
{
154
155
"decoder": {
155
-
"python": "tests/test_v5.py"
156
+
"sh": "tests/test_v5.py"
156
157
},
157
158
"encoder": {
158
-
"python": "tests/test_v5.py"
159
+
"sh": "tests/test_v5.py"
159
160
},
160
161
}
161
162
```
162
163
163
-
You can also specify `lua` and `rhai` values instead of `python`.
164
+
You can also specify `lua` and `rhai` values instead of `sh`.
165
+
166
+
### 5. Shell vs Rhai/Lua (`0.3` -> `0.4` migration)
167
+
168
+
If `lua` or `rhai` feature is enabled, `smart-patcher` can patch files without any external runtime dependencies. Unfortunately, Python can't be embedded within `smart-patcher` due to `pyo3` library, therefore now you can choose to shebang your Python scripts and use them again.
169
+
170
+
Nevertheless, API was slightly changed. Requests are written in JSON files and responses are read from JSON files too. See Python scripts implementations in `tests` folder to see how them are adapted to new `smart-patcher`.
171
+
172
+
For novices, in `smart-patcher v0.4` you can propose any scripts to handle next patch tasks: find, replace, and decode from/encode to any binary data. For Rhai/Lua scripts, you should write functions with proposed names (`find`, `replace`, `decode` and `encode`), and for shell scripts you should use file system I/O and JSON utilities to read requests and write responses in paths provided by command arguments.
0 commit comments