From 73502323624cf03e80383038b862c222d0213e6f Mon Sep 17 00:00:00 2001 From: engelgardt Date: Sun, 17 May 2026 21:41:34 +0300 Subject: [PATCH] v1.0.3: quiet update hint instead of interactive prompt --- CHANGELOG.md | 9 ++++++++- src/netswitch.ps1 | 48 +++++++++++++++++++++++------------------------ 2 files changed, 32 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 293ef22..0a36189 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and ## [Unreleased] +## [1.0.3] - 2026-05-17 +### Changed +- Update check no longer interrupts startup with an interactive prompt. If a newer release is available, a quiet right-aligned `update available (vX.Y.Z)` hint is printed in dim grey directly under the banner — no key press required. + ## [1.0.2] - 2026-05-17 ### Fixed - Suppress `netsh` output to avoid mojibake on non-UTF-8 consoles (Russian Windows printed `╤Г╨╢╨╡ ╨▓╨║╨╗╤О╤З╨╡╨╜╨╛...` because netsh emits in the OEM code page). Our own English status lines remain; the post-change `Get-NetIPAddress` block already prints Unicode. @@ -27,5 +31,8 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and - Auto-update check on startup: polls GitHub `/releases/latest` with a 3-second timeout and offers to open the download page if a newer version exists. Silent on offline / API errors. - MIT licensed. -[Unreleased]: https://github.com/Engelgardt23/netswitch/compare/v1.0.0...HEAD +[Unreleased]: https://github.com/Engelgardt23/netswitch/compare/v1.0.3...HEAD +[1.0.3]: https://github.com/Engelgardt23/netswitch/compare/v1.0.2...v1.0.3 +[1.0.2]: https://github.com/Engelgardt23/netswitch/compare/v1.0.1...v1.0.2 +[1.0.1]: https://github.com/Engelgardt23/netswitch/compare/v1.0.0...v1.0.1 [1.0.0]: https://github.com/Engelgardt23/netswitch/releases/tag/v1.0.0 diff --git a/src/netswitch.ps1 b/src/netswitch.ps1 index 7c71a74..e595a25 100644 --- a/src/netswitch.ps1 +++ b/src/netswitch.ps1 @@ -1,7 +1,7 @@ # netswitch v1.0.0 - quick NIC IP / DHCP toggle # made by engelgardt -$NetswitchVersion = '1.0.2' +$NetswitchVersion = '1.0.3' $GithubRepo = 'Engelgardt23/netswitch' $ErrorActionPreference = 'Stop' @@ -19,20 +19,13 @@ if (-not $me.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { exit } -# --- Banner --- -Write-Host "" -Write-Host "==============================================" -ForegroundColor Cyan -Write-Host " netswitch v$NetswitchVersion - NIC IP/DHCP toggle" -ForegroundColor Cyan -Write-Host "==============================================" -ForegroundColor Cyan -Write-Host "" - -# --- Update check --- -function Test-NetswitchUpdate { +# --- Update check (silent: returns latest tag if newer, else empty) --- +function Get-NetswitchUpdate { try { $url = "https://api.github.com/repos/$GithubRepo/releases/latest" $r = Invoke-RestMethod -Uri $url -TimeoutSec 3 -Headers @{ 'User-Agent' = "netswitch/$NetswitchVersion" } $latest = ($r.tag_name -as [string]) -replace '^v','' - if (-not $latest) { return } + if (-not $latest) { return '' } $toTuple = { param($s) $parts = ($s -split '\.') | ForEach-Object { $n = 0; [void][int]::TryParse($_, [ref]$n); $n @@ -42,24 +35,31 @@ function Test-NetswitchUpdate { } $L = & $toTuple $latest $C = & $toTuple $NetswitchVersion - $isNewer = $false for ($i = 0; $i -lt 3; $i++) { - if ($L[$i] -gt $C[$i]) { $isNewer = $true; break } - if ($L[$i] -lt $C[$i]) { break } - } - if ($isNewer) { - Write-Host "Update available: v$NetswitchVersion -> $($r.tag_name)" -ForegroundColor Yellow - $ans = Read-Host "Open the download page in your browser? [Y/n]" - if ($ans -notmatch '^(n|N|no|NO)$') { - Start-Process $r.html_url - } - Write-Host "" + if ($L[$i] -gt $C[$i]) { return $r.tag_name } + if ($L[$i] -lt $C[$i]) { return '' } } + return '' } catch { - # silent on offline / API errors + return '' } } -Test-NetswitchUpdate +$latestTag = Get-NetswitchUpdate + +# --- Banner --- +Write-Host "" +Write-Host "==============================================" -ForegroundColor Cyan +Write-Host " netswitch v$NetswitchVersion - NIC IP/DHCP toggle" -ForegroundColor Cyan +Write-Host "==============================================" -ForegroundColor Cyan +if ($latestTag) { + $msg = "update available ($latestTag)" + $w = 0 + try { $w = $Host.UI.RawUI.WindowSize.Width } catch { $w = 0 } + if ($w -lt ($msg.Length + 2)) { $w = $msg.Length + 2 } + $pad = $w - $msg.Length - 1 + Write-Host ((' ' * [Math]::Max(0, $pad)) + $msg) -ForegroundColor DarkGray +} +Write-Host "" # --- Pick adapter (physical wired only) --- $skipDescriptionPattern = 'VPN|Virtual|AnyConnect|TAP-|TUN-|Bluetooth|Loopback|WAN Miniport|Hyper-V|VMware|VirtualBox|WireGuard|OpenVPN|Tailscale|ZeroTier'