2024-08-20 16:47:25 +03:00
|
|
|
# Browser command line
|
2024-08-20 14:28:51 +03:00
|
|
|
|
2024-08-20 16:15:42 +03:00
|
|
|
The idea is to transform api methods in command line interface
|
2024-08-20 14:28:51 +03:00
|
|
|
|
2024-08-20 16:15:42 +03:00
|
|
|
The default shell command, like:
|
2024-08-20 14:28:51 +03:00
|
|
|
|
|
|
|
```sh
|
2024-08-20 16:15:42 +03:00
|
|
|
wacli <tool.dns> <api_methods>
|
2024-08-20 14:28:51 +03:00
|
|
|
```
|
|
|
|
|
2024-08-20 16:15:42 +03:00
|
|
|
You can also install localy
|
|
|
|
|
|
|
|
Binary, if exist
|
2024-08-20 14:28:51 +03:00
|
|
|
|
|
|
|
```sh
|
2024-08-20 16:15:42 +03:00
|
|
|
wacli bin <tool.dns>
|
2024-08-20 14:28:51 +03:00
|
|
|
```
|
|
|
|
|
2024-08-20 16:15:42 +03:00
|
|
|
API
|
2024-08-20 14:28:51 +03:00
|
|
|
|
2024-08-20 16:15:42 +03:00
|
|
|
```sh
|
|
|
|
wacli ain <tool.dns>
|
|
|
|
```
|
|
|
|
|
|
|
|
On your website you will need to use `.well-know/wacli.json` file:
|
|
|
|
|
|
|
|
```jsonc
|
2024-08-20 14:28:51 +03:00
|
|
|
{
|
2024-08-20 16:15:42 +03:00
|
|
|
"api": "<api_url>",
|
2024-08-20 14:28:51 +03:00
|
|
|
"bin": {
|
|
|
|
"<platform>": [{
|
|
|
|
"<architecture>": "<path_for_file"
|
|
|
|
}]
|
|
|
|
}
|
|
|
|
"settings": {
|
2024-08-20 16:15:42 +03:00
|
|
|
// By default using application json, and it doesn't need to be specified
|
|
|
|
"contentType": "application/json",
|
2024-08-20 14:28:51 +03:00
|
|
|
"aliases": [{
|
2024-08-20 16:15:42 +03:00
|
|
|
"alias": "<short_hand>" | ["short_hand","long_hand"],
|
2024-08-20 18:19:43 +03:00
|
|
|
"type": "path" | "method" | "bin",
|
2024-08-20 16:15:42 +03:00
|
|
|
"description": "description of cli command"
|
2024-08-20 18:19:43 +03:00
|
|
|
"content": "<path>"
|
2024-08-20 16:15:42 +03:00
|
|
|
}],
|
|
|
|
"auth": {
|
2024-08-20 18:19:43 +03:00
|
|
|
"scheme": "basic" | "bearer" | "oauth2"
|
|
|
|
"tokenName": "<name_of_token>" // - bearer
|
2024-08-20 16:15:42 +03:00
|
|
|
// oauth2
|
|
|
|
"flows": {
|
|
|
|
"implict": {
|
|
|
|
authorizationUrl: "url",
|
|
|
|
scopes: {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-08-20 14:28:51 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2024-08-20 16:15:42 +03:00
|
|
|
## Example as:
|
2024-08-20 14:28:51 +03:00
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
2024-08-20 18:19:43 +03:00
|
|
|
"api": "https://git.0ut0f.space/swagger.v1.json",
|
2024-08-20 14:28:51 +03:00
|
|
|
"settings": {
|
|
|
|
"aliases": [
|
|
|
|
{
|
2024-08-20 18:19:43 +03:00
|
|
|
"alias": "issues",
|
2024-08-20 14:28:51 +03:00
|
|
|
"type": "path",
|
2024-08-20 18:19:43 +03:00
|
|
|
"content": "/repos/{owner}/{repo}/issues"
|
2024-08-20 14:28:51 +03:00
|
|
|
},
|
|
|
|
{
|
2024-08-20 18:19:43 +03:00
|
|
|
"alias": ["c","create"],
|
2024-08-20 14:28:51 +03:00
|
|
|
"type": "method",
|
2024-08-20 18:19:43 +03:00
|
|
|
"content": "POST"
|
2024-08-20 14:28:51 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"alias": "tea",
|
|
|
|
"type": "bin",
|
2024-08-20 18:19:43 +03:00
|
|
|
"content": "tea"
|
2024-08-20 14:28:51 +03:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"bin": {
|
2024-08-20 18:19:43 +03:00
|
|
|
"linux": [{"x86": "https://dl.gitea.com/tea/main/tea-main-linux-amd64.xz"}],
|
|
|
|
"windows": [{"x86": "https://dl.gitea.com/tea/main/tea-main-windows-amd64.xz"}],
|
|
|
|
"darwin": [
|
|
|
|
{"arm64": "https://dl.gitea.com/tea/main/tea-main-darwin-arm64"},
|
|
|
|
{"x86": "https://dl.gitea.com/tea/main/tea-main-darwin-amd64.xz"}
|
|
|
|
]
|
2024-08-20 14:28:51 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2024-08-20 18:19:43 +03:00
|
|
|
Next REST API - `https://git.0ut0f.space/api/v1/repos/{owner}/{repo}/issues` method is transform command:
|
2024-08-20 14:28:51 +03:00
|
|
|
|
2024-08-20 16:15:42 +03:00
|
|
|
By default - GET request:
|
2024-08-20 14:28:51 +03:00
|
|
|
|
|
|
|
```sh
|
2024-08-20 18:19:43 +03:00
|
|
|
wacli git.0ut0f.space repos issues [owner] [repo]
|
2024-08-20 14:28:51 +03:00
|
|
|
```
|
|
|
|
|
2024-08-20 16:15:42 +03:00
|
|
|
If you need a request other than GET, then add the command
|
2024-08-20 14:28:51 +03:00
|
|
|
|
|
|
|
```sh
|
2024-08-20 18:19:43 +03:00
|
|
|
wacli git.0ut0f.space post|delete|put|path repos issues [owner] [repo]
|
2024-08-20 14:28:51 +03:00
|
|
|
```
|
|
|
|
|
2024-08-20 16:15:42 +03:00
|
|
|
Such requests may require authorization, so you must log in separately:
|
2024-08-20 14:28:51 +03:00
|
|
|
|
|
|
|
```sh
|
2024-08-20 18:19:43 +03:00
|
|
|
wacli auth git.0ut0f.space
|
2024-08-20 14:28:51 +03:00
|
|
|
```
|
|
|
|
|
2024-08-20 16:15:42 +03:00
|
|
|
tokens are stored separately in the database.
|
2024-08-20 14:28:51 +03:00
|
|
|
|
2024-08-20 16:15:42 +03:00
|
|
|
Methods can be overridden:
|
2024-08-20 14:28:51 +03:00
|
|
|
|
|
|
|
```sh
|
2024-08-20 18:19:43 +03:00
|
|
|
wacli git.0ut0f.space create repos issues [owner] [repo]
|
2024-08-20 14:28:51 +03:00
|
|
|
```
|
|
|
|
|
2024-08-20 16:15:42 +03:00
|
|
|
By default, all request in clearnet and tor go via `https`, but i2p - `http`.
|
2024-08-20 14:28:51 +03:00
|
|
|
|
2024-08-20 16:15:42 +03:00
|
|
|
But sometimes you need to specify a specific protocol
|
2024-08-20 14:28:51 +03:00
|
|
|
|
|
|
|
```sh
|
2024-08-20 18:19:43 +03:00
|
|
|
wacli bin "git+http://git.0ut0f.space/"
|
2024-08-20 14:28:51 +03:00
|
|
|
```
|
|
|
|
|
2024-08-20 16:15:42 +03:00
|
|
|
Binaries is install of user directory `$HOME/.local/bin`, for root user - `/usr/local/bin`.
|
2024-08-20 16:47:25 +03:00
|
|
|
|
|
|
|
Perhaps not everyone will add tools to their sites, so for popular tools using directive:
|
|
|
|
|
|
|
|
```sh
|
2024-08-20 18:19:43 +03:00
|
|
|
wacli registry:forgejo repos issues
|
2024-08-20 16:47:25 +03:00
|
|
|
```
|
|
|
|
|
|
|
|
You can also get help on all api methods using the command
|
|
|
|
|
|
|
|
```sh
|
|
|
|
wacli help codeberg.org
|
|
|
|
```
|