2025-05-28 17:36:06 +02:00
|
|
|
# Template for Knoc plugins
|
|
|
|
|
|
|
|
## Entry points
|
|
|
|
|
|
|
|
It has 4 standard entry points, defined in `pyproject.toml`:
|
|
|
|
|
|
|
|
* CLI
|
|
|
|
* workflow
|
|
|
|
* api
|
|
|
|
* settings
|
|
|
|
|
|
|
|
## CI
|
|
|
|
|
|
|
|
It has a Forgejo CI build action, defined in `.forgejo/actions/build.yaml`.
|
|
|
|
|
2025-05-28 16:37:10 +00:00
|
|
|
## Usage
|
|
|
|
|
2025-05-28 17:11:44 +00:00
|
|
|
Just replace `foo` by the name of the plugin below.
|
|
|
|
|
|
|
|
With `fish`:
|
2025-05-28 17:01:04 +00:00
|
|
|
|
2025-05-28 16:37:10 +00:00
|
|
|
```fish
|
2025-05-28 17:01:04 +00:00
|
|
|
set NAME foo
|
|
|
|
set PNAME knoc_$NAME
|
2025-05-28 16:37:10 +00:00
|
|
|
set DNAME (echo $NAME | tr "_" "-")
|
|
|
|
```
|
|
|
|
|
|
|
|
or with bash:
|
|
|
|
```bash
|
2025-05-28 17:01:23 +00:00
|
|
|
NAME=foo
|
2025-05-28 17:01:04 +00:00
|
|
|
PNAME=knoc_$NAME
|
2025-05-28 16:37:10 +00:00
|
|
|
DNAME=$(echo $NAME | tr "_" "-")
|
|
|
|
```
|
|
|
|
|
|
|
|
Then:
|
|
|
|
```fish
|
2025-05-28 16:45:19 +00:00
|
|
|
git clone https://code.philo.ydns.eu/K-Net/knoc-plugin-template.git $DNAME
|
|
|
|
cd $DNAME
|
2025-05-28 16:37:10 +00:00
|
|
|
rm -rf .git
|
|
|
|
mv src/knoc_plugin_template src/$NAME
|
2025-05-28 17:01:04 +00:00
|
|
|
sed "s/plugin_template/$NAME/" -i pyproject.toml
|
2025-05-28 16:37:10 +00:00
|
|
|
sed "s/knoc-plugin-template/$DNAME/" -i pyproject.toml
|
2025-05-28 17:03:52 +00:00
|
|
|
sed "s/plugin_template/$NAME/" -i src/$PNAME/api.py
|
|
|
|
sed "s/plugin_template/$NAME/" -i src/$PNAME/cli.py
|
|
|
|
sed "s/plugin_template/$NAME/" -i src/$PNAME/settings.py
|
|
|
|
sed "s/plugin_template/$NAME/" -i src/$PNAME/workflows.py
|
|
|
|
uv venv
|
2025-05-28 17:11:44 +00:00
|
|
|
git init
|
|
|
|
```
|
|
|
|
|
|
|
|
Then, with `fish`:
|
|
|
|
```fish
|
|
|
|
. .venv/bin/activate.fish
|
|
|
|
uv sync
|
|
|
|
```
|
|
|
|
|
|
|
|
Or `bash`:
|
|
|
|
```bash
|
|
|
|
. .venv/bin/activate
|
|
|
|
uv sync
|
2025-05-28 16:37:10 +00:00
|
|
|
```
|
2025-05-28 17:11:44 +00:00
|
|
|
|
2025-05-28 17:13:26 +00:00
|
|
|
=> The package is ready.
|
2025-05-28 17:11:44 +00:00
|
|
|
|
|
|
|
In a *knoc* development environment:
|
|
|
|
```fish
|
|
|
|
uv pip install -e ../$DNAME
|
|
|
|
knoc # Should display the new plugin's CLI tool
|
2025-05-28 17:13:26 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
Finally, set the git upstream, edit, commit, tag, push.
|