mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 13:01:32 +00:00
Provide full event handler API documentation
This commit is contained in:
parent
5262401b18
commit
f78f01d6e1
158
README.md
158
README.md
@ -107,6 +107,162 @@ Broadcasting messages is possible in a similar manner by using `"key": "broadcas
|
||||
|
||||
Most of the components you need have docstrings included (hang on tight, this is work in progress) – refer to them for usage info.
|
||||
|
||||
In the `docs` folder you can find our Sphinx-based API documentation, which you can build using the `hack/tfw.sh` script in the [test-tutorial-framework](https://github.com/avatao-content/test-tutorial-framework) repository.
|
||||
In the `docs` folder you can find our Sphinx-based documentation, which you can build using the `hack/tfw.sh` script in the [test-tutorial-framework](https://github.com/avatao-content/test-tutorial-framework) repository.
|
||||
|
||||
To get started you should take a look at [test-tutorial-framework](https://github.com/avatao-content/test-tutorial-framework), which serves as an example project as well.
|
||||
|
||||
## API
|
||||
|
||||
APIs exposed by our pre-witten event handlers are documented here.
|
||||
|
||||
### IdeEventHandler
|
||||
|
||||
You can read the content of the currently selected file like so:
|
||||
```
|
||||
{
|
||||
"key": "ide",
|
||||
"data":
|
||||
{
|
||||
"command": "read"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Use the following message to overwrite the content of the currently selected file:
|
||||
```
|
||||
{
|
||||
"key": "ide",
|
||||
"data":
|
||||
{
|
||||
"command": "write",
|
||||
"content": ...string...
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
To select a file use the following message:
|
||||
```
|
||||
{
|
||||
"key": "ide",
|
||||
"data":
|
||||
{
|
||||
"command": "select",
|
||||
"filename": ...string...
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
You can switch to a new working directory using this message (note that the directory must be in `allowed_directories`):
|
||||
```
|
||||
{
|
||||
"key": "ide",
|
||||
"data":
|
||||
{
|
||||
"command": "selectdir",
|
||||
"directory": ...string...
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Overwriting the current list of excluded file patterns is possible with this message:
|
||||
```
|
||||
{
|
||||
"key": "ide",
|
||||
"data":
|
||||
{
|
||||
"command": "exclude",
|
||||
"exclude": ...array of strings...
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### TerminalEventHandler
|
||||
|
||||
Writing to the terminal:
|
||||
```
|
||||
{
|
||||
"key": "shell",
|
||||
"data":
|
||||
{
|
||||
"command": "write",
|
||||
"value": ...string...
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
You can read terminal command history like so:
|
||||
```
|
||||
{
|
||||
"key": "shell",
|
||||
"data":
|
||||
{
|
||||
"command": "read",
|
||||
"count": ...number...
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### ProcessManagingEventHandler
|
||||
|
||||
Starting, stopping and restarting supervisor processes can be done using similar messages (where `command` is `start`, `stop` or `restart`):
|
||||
```
|
||||
{
|
||||
"key": "processmanager",
|
||||
"data":
|
||||
{
|
||||
"command": ...string...,
|
||||
"process_name": ...string...
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### LogMonitoringEventHandler
|
||||
|
||||
To change which supervisor process is monitored use this message:
|
||||
```
|
||||
{
|
||||
"key": "logmonitor",
|
||||
"data" :
|
||||
{
|
||||
"command": "process_name",
|
||||
"value": ...string...
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
To set the tail length of logs (the monitor will send back the last `value` characters of the log):
|
||||
```
|
||||
{
|
||||
"key": "logmonitor",
|
||||
"data" :
|
||||
{
|
||||
"command": "log_tail",
|
||||
"value": ...number...
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### FSMManagingEventHandler
|
||||
|
||||
To attempt executing a trigger on the FSM use:
|
||||
```
|
||||
{
|
||||
"key": "fsm",
|
||||
"data" :
|
||||
{
|
||||
"command": "trigger",
|
||||
"value": ...string...
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
To force the broadcasting of an FSM update you can use this message:
|
||||
```
|
||||
{
|
||||
"key": "fsm",
|
||||
"data" :
|
||||
{
|
||||
"command": "update"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user