v1.0.3: quiet update hint instead of interactive prompt
This commit is contained in:
parent
67447bc7f1
commit
7350232362
2 changed files with 32 additions and 25 deletions
|
|
@ -6,6 +6,10 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
|
||||||
|
|
||||||
## [Unreleased]
|
## [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
|
## [1.0.2] - 2026-05-17
|
||||||
### Fixed
|
### 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.
|
- 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.
|
- 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.
|
- 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
|
[1.0.0]: https://github.com/Engelgardt23/netswitch/releases/tag/v1.0.0
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
# netswitch v1.0.0 - quick NIC IP / DHCP toggle
|
# netswitch v1.0.0 - quick NIC IP / DHCP toggle
|
||||||
# made by engelgardt
|
# made by engelgardt
|
||||||
|
|
||||||
$NetswitchVersion = '1.0.2'
|
$NetswitchVersion = '1.0.3'
|
||||||
$GithubRepo = 'Engelgardt23/netswitch'
|
$GithubRepo = 'Engelgardt23/netswitch'
|
||||||
|
|
||||||
$ErrorActionPreference = 'Stop'
|
$ErrorActionPreference = 'Stop'
|
||||||
|
|
@ -19,20 +19,13 @@ if (-not $me.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
# --- Banner ---
|
# --- Update check (silent: returns latest tag if newer, else empty) ---
|
||||||
Write-Host ""
|
function Get-NetswitchUpdate {
|
||||||
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 {
|
|
||||||
try {
|
try {
|
||||||
$url = "https://api.github.com/repos/$GithubRepo/releases/latest"
|
$url = "https://api.github.com/repos/$GithubRepo/releases/latest"
|
||||||
$r = Invoke-RestMethod -Uri $url -TimeoutSec 3 -Headers @{ 'User-Agent' = "netswitch/$NetswitchVersion" }
|
$r = Invoke-RestMethod -Uri $url -TimeoutSec 3 -Headers @{ 'User-Agent' = "netswitch/$NetswitchVersion" }
|
||||||
$latest = ($r.tag_name -as [string]) -replace '^v',''
|
$latest = ($r.tag_name -as [string]) -replace '^v',''
|
||||||
if (-not $latest) { return }
|
if (-not $latest) { return '' }
|
||||||
$toTuple = { param($s)
|
$toTuple = { param($s)
|
||||||
$parts = ($s -split '\.') | ForEach-Object {
|
$parts = ($s -split '\.') | ForEach-Object {
|
||||||
$n = 0; [void][int]::TryParse($_, [ref]$n); $n
|
$n = 0; [void][int]::TryParse($_, [ref]$n); $n
|
||||||
|
|
@ -42,24 +35,31 @@ function Test-NetswitchUpdate {
|
||||||
}
|
}
|
||||||
$L = & $toTuple $latest
|
$L = & $toTuple $latest
|
||||||
$C = & $toTuple $NetswitchVersion
|
$C = & $toTuple $NetswitchVersion
|
||||||
$isNewer = $false
|
|
||||||
for ($i = 0; $i -lt 3; $i++) {
|
for ($i = 0; $i -lt 3; $i++) {
|
||||||
if ($L[$i] -gt $C[$i]) { $isNewer = $true; break }
|
if ($L[$i] -gt $C[$i]) { return $r.tag_name }
|
||||||
if ($L[$i] -lt $C[$i]) { break }
|
if ($L[$i] -lt $C[$i]) { return '' }
|
||||||
}
|
}
|
||||||
if ($isNewer) {
|
return ''
|
||||||
Write-Host "Update available: v$NetswitchVersion -> $($r.tag_name)" -ForegroundColor Yellow
|
} catch {
|
||||||
$ans = Read-Host "Open the download page in your browser? [Y/n]"
|
return ''
|
||||||
if ($ans -notmatch '^(n|N|no|NO)$') {
|
}
|
||||||
Start-Process $r.html_url
|
}
|
||||||
|
$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 ""
|
Write-Host ""
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
# silent on offline / API errors
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Test-NetswitchUpdate
|
|
||||||
|
|
||||||
# --- Pick adapter (physical wired only) ---
|
# --- Pick adapter (physical wired only) ---
|
||||||
$skipDescriptionPattern = 'VPN|Virtual|AnyConnect|TAP-|TUN-|Bluetooth|Loopback|WAN Miniport|Hyper-V|VMware|VirtualBox|WireGuard|OpenVPN|Tailscale|ZeroTier'
|
$skipDescriptionPattern = 'VPN|Virtual|AnyConnect|TAP-|TUN-|Bluetooth|Loopback|WAN Miniport|Hyper-V|VMware|VirtualBox|WireGuard|OpenVPN|Tailscale|ZeroTier'
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue