Some checks failed
release / build-release (push) Failing after 4m23s
Rust CLI for Nginx Proxy Manager via its API, with sudo-like token auth (login prompts for password, caches only a short-lived token, never the password) and a generic `api` command to talk to any HTTP API. Commands: login/logout/status, list-hosts/get-host/find, add-proxy, enable/disable/delete-host, list-certs/add-cert/renew-cert, dump (JSON backup), apply (declarative), and generic api (method/url/header/data/ auth-key/insecure). Includes clap help + help-on-bad-input, Gitea Actions release workflow (arm64 native + x64 cross), VS Code build task (-> ./build), README and MIT license. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011YPrEZVBpPVoCRyJz2exkZ
67 lines
2.2 KiB
Markdown
67 lines
2.2 KiB
Markdown
# npmctl
|
|
|
|
En liten CLI i Rust för att styra **Nginx Proxy Manager (NPM)** via dess API,
|
|
plus en generisk `api`-funktion för att prata med vilket HTTP-API som helst
|
|
(framtidssäkring om proxyn byts ut mot t.ex. Caddy/Traefik).
|
|
|
|
Autentisering fungerar som `sudo`: kör `npmctl login` **en gång** och skriv
|
|
lösenordet i prompten (det når aldrig argv/loggar). En kortlivad token cachas
|
|
lokalt (`~/.config/npmctl/session.json`, `0600`) och används tills den går ut —
|
|
lösenordet sparas aldrig.
|
|
|
|
👉 **Användning och alla kommandon:** se [wiki:n](https://gitea.brasse-pc.eu/brasse/Npm-cli/wiki).
|
|
|
|
## Installera (färdig binär)
|
|
|
|
Hämta senaste binär från [releases](https://gitea.brasse-pc.eu/brasse/Npm-cli/releases):
|
|
|
|
```sh
|
|
# välj arkitektur: x64 eller arm64
|
|
curl -fsSL -o npmctl https://gitea.brasse-pc.eu/brasse/Npm-cli/releases/download/latest/npmctl-linux-x64
|
|
chmod +x npmctl && sudo mv npmctl /usr/local/bin/
|
|
npmctl --help
|
|
```
|
|
|
|
## Sätt upp projektet (utveckling)
|
|
|
|
Krav: [Rust](https://rustup.rs) (stable).
|
|
|
|
```sh
|
|
git clone https://gitea.brasse-pc.eu/brasse/Npm-cli.git
|
|
cd Npm-cli
|
|
cargo build --release # binär i target/release/npmctl
|
|
cargo run -- --help
|
|
```
|
|
|
|
### Bygga till ./build
|
|
|
|
I VS Code: **Terminal → Run Build Task** (`Ctrl+Shift+B`) kör tasken
|
|
*build (release -> ./build)*, som bygger utanför repo-disken och lägger binären
|
|
i `build/npmctl`. Mappen `build/` (och `target/`) är gitignoread.
|
|
|
|
Motsvarande manuellt:
|
|
|
|
```sh
|
|
CARGO_TARGET_DIR="$HOME/.cache/npmctl-target" cargo build --release
|
|
mkdir -p build && cp "$HOME/.cache/npmctl-target/release/npmctl" build/npmctl
|
|
```
|
|
|
|
## Releaser
|
|
|
|
Push till `main` (eller en `v*`-tag) triggar Gitea Actions-workflowen
|
|
`.gitea/workflows/release.yaml`, som bygger binärer för **linux-x64** och
|
|
**linux-arm64** och laddar upp dem till en release. Runnern använder sin egen
|
|
`GITHUB_TOKEN` — ingen token hanteras manuellt.
|
|
|
|
## Konfiguration
|
|
|
|
| Var | Beskrivning |
|
|
|-----|-------------|
|
|
| `--base-url` / `NPMCTL_BASE_URL` | NPM:s API-bas, t.ex. `http://127.0.0.1:81`. Standard: `http://127.0.0.1:81`. |
|
|
| `~/.config/npmctl/config.json` | Icke-hemligt: `base_url`, `identity`, `idle_timeout`. |
|
|
| `~/.config/npmctl/session.json` | Cachad token (`0600`). Skapas av `login`, raderas av `logout`. |
|
|
|
|
## Licens
|
|
|
|
MIT.
|