2023-08-25 15:08:39 +00:00
|
|
|
# clan-cli
|
|
|
|
|
|
|
|
The clan-cli contains the command line interface as well as the graphical webui through the `clan webui` command.
|
|
|
|
|
|
|
|
## Hacking on the cli
|
|
|
|
|
|
|
|
We recommend setting up [direnv](https://direnv.net/) to load the developement with nix.
|
|
|
|
If you do not have it set up you can also use `nix develop` directly like this:
|
|
|
|
|
|
|
|
```
|
|
|
|
use flake .#clan-cli --builders ''
|
|
|
|
```
|
|
|
|
|
|
|
|
After you can use the local bin wrapper to test things in the cli:
|
|
|
|
|
|
|
|
```
|
|
|
|
./bin/clan
|
|
|
|
```
|
|
|
|
|
|
|
|
## Hacking on the webui
|
|
|
|
|
|
|
|
By default the webui is build from a tarball available https://git.clan.lol/clan/-/packages/generic/ui/.
|
|
|
|
To start a local developement environment instead, use the `--dev` flag:
|
|
|
|
|
|
|
|
```
|
|
|
|
./bin/clan webui --dev
|
|
|
|
```
|
|
|
|
|
|
|
|
This will spawn two webserver, a python one to for the api and a nodejs one that rebuilds the ui on the fly.
|
2023-08-30 09:28:07 +00:00
|
|
|
|
2023-09-22 16:44:05 +00:00
|
|
|
## Run webui directly
|
2023-09-25 14:28:32 +00:00
|
|
|
|
2023-09-22 16:44:05 +00:00
|
|
|
Useful for vscode run and debug option
|
2023-09-25 14:28:32 +00:00
|
|
|
|
2023-09-22 16:44:05 +00:00
|
|
|
```bash
|
|
|
|
python -m clan_cli.webui --reload --no-open
|
|
|
|
```
|
|
|
|
|
|
|
|
Add this `launch.json` to your .vscode directory to have working breakpoints in your vscode editor.
|
2023-09-25 14:28:32 +00:00
|
|
|
|
2023-09-22 16:44:05 +00:00
|
|
|
```json
|
|
|
|
{
|
2023-09-25 14:28:32 +00:00
|
|
|
"version": "0.2.0",
|
|
|
|
"configurations": [
|
|
|
|
{
|
|
|
|
"name": "Clan Webui",
|
|
|
|
"type": "python",
|
|
|
|
"request": "launch",
|
|
|
|
"module": "clan_cli.webui",
|
|
|
|
"justMyCode": true,
|
|
|
|
"args": ["--reload", "--no-open", "--log-level", "debug"]
|
|
|
|
}
|
|
|
|
]
|
2023-09-22 16:44:05 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2023-08-30 09:28:07 +00:00
|
|
|
## Run locally single-threaded for debugging
|
|
|
|
|
|
|
|
By default tests run in parallel using pytest-parallel.
|
|
|
|
pytest-parallel however breaks `breakpoint()`. To disable it, use this:
|
|
|
|
|
|
|
|
```console
|
2023-10-23 20:31:12 +00:00
|
|
|
pytest -n0 -s
|
2023-08-30 09:28:07 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
You can also run a single test like this:
|
|
|
|
|
|
|
|
```console
|
2023-10-23 20:31:12 +00:00
|
|
|
pytest -n0 -s tests/test_secrets_cli.py::test_users
|
2023-08-30 09:28:07 +00:00
|
|
|
```
|
2023-10-23 20:31:12 +00:00
|
|
|
|
2023-10-29 18:35:29 +00:00
|
|
|
## Run tests in nix container
|
|
|
|
|
|
|
|
Run all impure checks
|
|
|
|
|
|
|
|
```console
|
|
|
|
nix run .#impure-checks
|
|
|
|
```
|
|
|
|
|
|
|
|
Run all checks
|
|
|
|
|
|
|
|
```console
|
|
|
|
nix flake check
|
|
|
|
```
|
|
|
|
|
2023-10-23 20:31:12 +00:00
|
|
|
## Debugging functions
|
2023-10-23 20:34:43 +00:00
|
|
|
|
2023-10-23 20:31:12 +00:00
|
|
|
Debugging functions can be found under `src/debug.py`
|
2023-10-29 18:35:29 +00:00
|
|
|
quite interesting is the function breakpoint_shell() which drops you into a shell
|
2023-10-23 20:31:12 +00:00
|
|
|
with the test environment loaded.
|