# hlog CLI installer for Windows — https://hlog.dev/docs/cli # usage: irm https://hlog.dev/install.ps1 | iex $ErrorActionPreference = 'Stop' $ProgressPreference = 'SilentlyContinue' if (-not [Environment]::Is64BitOperatingSystem) { throw 'hlog: only 64-bit Windows is supported' } $asset = 'hlog-x86_64-pc-windows-msvc.zip' $base = 'https://github.com/siddharthsingh89/hlog-cli/releases/latest/download' $dir = Join-Path $env:LOCALAPPDATA 'hlog\bin' $tmp = Join-Path ([IO.Path]::GetTempPath()) ('hlog-' + [Guid]::NewGuid()) New-Item -ItemType Directory -Force -Path $tmp | Out-Null try { Write-Host "downloading $asset ..." Invoke-WebRequest -UseBasicParsing "$base/$asset" -OutFile (Join-Path $tmp $asset) Invoke-WebRequest -UseBasicParsing "$base/$asset.sha256" -OutFile (Join-Path $tmp "$asset.sha256") $expected = ((Get-Content (Join-Path $tmp "$asset.sha256") -Raw).Trim() -split '\s+')[0].ToLower() $actual = (Get-FileHash (Join-Path $tmp $asset) -Algorithm SHA256).Hash.ToLower() if ($expected -ne $actual) { throw 'hlog: checksum mismatch - not installing' } New-Item -ItemType Directory -Force -Path $dir | Out-Null Expand-Archive -Force (Join-Path $tmp $asset) -DestinationPath $dir Write-Host "installed: $dir\hlog.exe" $userPath = [Environment]::GetEnvironmentVariable('Path', 'User') if (-not (($userPath -split ';') -contains $dir)) { [Environment]::SetEnvironmentVariable('Path', ($userPath.TrimEnd(';') + ';' + $dir).TrimStart(';'), 'User') $env:Path = $env:Path + ';' + $dir Write-Host "added $dir to your PATH (open a new terminal if 'hlog' isn't found)" } # Another hlog earlier on the PATH (an old cargo install, say) would run instead of this one. $exe = [IO.Path]::GetFullPath((Join-Path $dir 'hlog.exe')) $first = Get-Command hlog -CommandType Application -ErrorAction SilentlyContinue | Select-Object -First 1 if ($first -and ([IO.Path]::GetFullPath($first.Source) -ne $exe)) { $v = try { & $first.Source --version 2>$null } catch { 'unknown version' } Write-Warning "another hlog ($v) at $($first.Source) comes first on your PATH, so 'hlog' runs that one." if ($first.Source -like '*\.cargo\bin\*') { Write-Host ' fix: cargo uninstall hlog (or update it: cargo install hlog)' } elseif ($first.Source -like '*\scoop\*') { Write-Host ' fix: scoop uninstall hlog (or update it: scoop update hlog)' } else { Write-Host " fix: delete it, or move $dir earlier in your PATH" } } Write-Host 'next: hlog login' } finally { Remove-Item -Recurse -Force $tmp -ErrorAction SilentlyContinue }