mirror of
https://github.com/TECHNOFAB11/pay-respects.git
synced 2026-02-02 07:35:10 +01:00
add: Rule explanation in README
This commit is contained in:
parent
cb8f597fc3
commit
3ed775ef4b
1 changed files with 33 additions and 0 deletions
33
README.md
33
README.md
|
|
@ -11,6 +11,39 @@ alias f="pay_respect"
|
||||||
```
|
```
|
||||||
You can now **press `F` to Pay Respect**!
|
You can now **press `F` to Pay Respect**!
|
||||||
|
|
||||||
|
## Rule Files
|
||||||
|
|
||||||
|
Rule files are parsed at compilation. What actually gets compiled is a HashMap that contains patterns and suggestions for a specific command.
|
||||||
|
|
||||||
|
Syntax of a rule file (placed under [rules](./rules)):
|
||||||
|
```toml
|
||||||
|
# this field should be the name of the command
|
||||||
|
command = "world"
|
||||||
|
|
||||||
|
# you can add as much section of like this as you like
|
||||||
|
[[match_output]]
|
||||||
|
# the suggestion of this section will be used for the following patterns of the command output
|
||||||
|
pattern = [
|
||||||
|
"pattern 1",
|
||||||
|
"pattern 2",
|
||||||
|
]
|
||||||
|
# this will keep the change the second argument to `fix`
|
||||||
|
suggest = "{{command[0]}} fix {{command[2:]}}"
|
||||||
|
|
||||||
|
[[match_output]]
|
||||||
|
pattern = [
|
||||||
|
"pattern 1",
|
||||||
|
]
|
||||||
|
# this will add a `sudo` before the command, without touching the rest
|
||||||
|
suggest = "sudo {{command}}"
|
||||||
|
```
|
||||||
|
|
||||||
|
The placeholder is evaluated as following:
|
||||||
|
|
||||||
|
- `{{command}}`: All the command without any modification
|
||||||
|
- `{{command[1]}}`: The first argument of the command (the command itself has index of 0)
|
||||||
|
- `{{command[2:5]}}`: The second to fifth arguments. If any of the side is not specified, them it defaults to the start (if it is left) or the end (if it is right).
|
||||||
|
|
||||||
## Current Progress
|
## Current Progress
|
||||||
|
|
||||||
Currently, only correction to `sudo` permission is implemented.
|
Currently, only correction to `sudo` permission is implemented.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue