wacli/readme.md

126 lines
2.6 KiB
Markdown
Raw Normal View History

2024-08-20 16:15:42 +03:00
# Command line getting from browser
2024-08-20 16:15:42 +03:00
The idea is to transform api methods in command line interface
2024-08-20 16:15:42 +03:00
The default shell command, like:
```sh
2024-08-20 16:15:42 +03:00
wacli <tool.dns> <api_methods>
```
2024-08-20 16:15:42 +03:00
You can also install localy
Binary, if exist
```sh
2024-08-20 16:15:42 +03:00
wacli bin <tool.dns>
```
2024-08-20 16:15:42 +03:00
API
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 16:15:42 +03:00
"api": "<api_url>",
"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",
"aliases": [{
2024-08-20 16:15:42 +03:00
"alias": "<short_hand>" | ["short_hand","long_hand"],
"type": "path" | "method",
"description": "description of cli command"
"path": "<path>"
2024-08-20 16:15:42 +03:00
}],
"auth": {
"sheme": "basic" | "bearer" | "oauth2"
"token": "<name_of_token>" // - bearer
// oauth2
"flows": {
"implict": {
authorizationUrl: "url",
scopes: {}
}
}
}
}
}
```
2024-08-20 16:15:42 +03:00
## Example as:
```json
{
"api": "https://codeberg.org/api/v1",
"settings": {
"aliases": [
{
"alias": "i",
"type": "path",
"path": "/repos/{owner}/{repo}/issues"
},
{
"alias": "create",
"type": "method",
"method": "POST"
},
{
"alias": "tea",
"type": "bin",
"bin": "tea"
}
]
},
"bin": {
"linux": [{"x86": "https://dl.gitea.com/tea/main/tea-main-linux-amd64.xz"}]
}
}
```
2024-08-20 16:15:42 +03:00
Next REST API - `https://codeberg.org/api/v1/repos/{owner}/{repo}/issues` method is transform command:
2024-08-20 16:15:42 +03:00
By default - GET request:
```sh
2024-08-20 16:15:42 +03:00
wacli codeberg.org repos issues [owner] [repo]
```
2024-08-20 16:15:42 +03:00
If you need a request other than GET, then add the command
```sh
2024-08-20 16:15:42 +03:00
wacli codeberg.org post|delete|put|path repos issues [owner] [repo]
```
2024-08-20 16:15:42 +03:00
Such requests may require authorization, so you must log in separately:
```sh
2024-08-20 16:15:42 +03:00
wacli auth codeberg.org
```
2024-08-20 16:15:42 +03:00
tokens are stored separately in the database.
2024-08-20 16:15:42 +03:00
Methods can be overridden:
```sh
2024-08-20 16:15:42 +03:00
wacli codeberg.org create repos issues [owner] [repo]
```
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 16:15:42 +03:00
But sometimes you need to specify a specific protocol
```sh
2024-08-20 16:15:42 +03:00
pwact bin "git+http://codeberg.org/"
```
2024-08-20 16:15:42 +03:00
Binaries is install of user directory `$HOME/.local/bin`, for root user - `/usr/local/bin`.