From c91dbe9f7dcf8c239153a815b20a357d23389294 Mon Sep 17 00:00:00 2001 From: Michael Wesemann Date: Mon, 26 Oct 2026 16:25:36 +0100 Subject: [PATCH] Add self-update, release 1.0.2 nscan update installs the newest release from git.micw.org, nscan update -c only checks; --update and --check-update work as well. The download lands next to the running binary, is started once with --version and only then replaces it. Once a day an ordinary run asks in the background and mentions a newer release in the title bar and on stderr, only on a terminal and not with NSCAN_NO_UPDATE_CHECK set. selfupdate.go is goca's copyable template. Co-Authored-By: Claude Opus 5.5 (1M context) --- CHANGELOG.md | 7 + README.md | 27 +- internal/tui/model.go | 1 + internal/tui/model_test.go | 13 + internal/tui/theme.go | 1 + internal/tui/view.go | 7 + main.go | 68 ++++- selfupdate.go | 494 +++++++++++++++++++++++++++++++++++++ selfupdate_test.go | 155 ++++++++++++ version.go | 2 +- version.txt | 2 +- 11 files changed, 761 insertions(+), 16 deletions(-) create mode 100644 selfupdate.go create mode 100644 selfupdate_test.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 38d9671..1864ef3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## 1.0.2 – 2026-10-26 + +- Self-update: `nscan update` installs the newest release, `nscan update -c` only + checks (also `--update` and `--check-update`). Once a day nscan checks in the + background and mentions a newer release in the title bar and on stderr; set + `NSCAN_NO_UPDATE_CHECK=1` to turn that off. + ## 1.0.1 – 2026-10-26 - The device list sizes its columns to their content and gives the remaining width to diff --git a/README.md b/README.md index c4668a7..865c592 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ Download the file for your system from the | Linux, ARM64 (e.g. Pi) | `nscan-linux-arm64` | ```sh -curl -fLo nscan https://git.micw.org/mike/nscan/releases/download/1.0.1/nscan-darwin-arm64 +curl -fLo nscan https://git.micw.org/mike/nscan/releases/download/1.0.2/nscan-darwin-arm64 chmod +x nscan sudo mv nscan /usr/local/bin/ ``` @@ -78,6 +78,26 @@ cd nscan go build -o nscan . ``` +### Updating + +```sh +nscan update # download the newest release and replace the running binary +nscan update -c # only check +``` + +`--update` and `--check-update` work as well. If nscan lives in a directory you cannot +write to, such as `/usr/local/bin`, run `sudo nscan update`. The new binary is downloaded +next to the old one and started once with `--version` before it replaces the old one, +so a broken download never takes its place. + +Once a day, nscan also asks git.micw.org in the background whether there is a newer +release. If so, it says so on the next run: in the title bar of the interface, and as a +line on stderr after a command. Nothing is installed without `nscan update`. The check +stays quiet when stderr is not a terminal (pipes, scripts, cron). Set +`NSCAN_NO_UPDATE_CHECK=1` to turn it off. + +Self-update arrived in 1.0.2. Replace older versions by hand once. + ## Quick start ```sh @@ -173,6 +193,7 @@ nscan interfaces list network interfaces nscan oui update download the vendor database from the IEEE nscan oui import import oui.csv/oui.txt manually nscan oui lookup show the vendor of a MAC address +nscan update [-c] install the newest release (-c: only check) nscan version print the version ``` @@ -250,6 +271,10 @@ nscan keeps its state in `~/.config/nscan/` (or `$XDG_CONFIG_HOME/nscan`, or Devices are keyed by MAC address, so a custom name follows a device when its IP address changes. Exports (e) go to `nscan--