Skip to content

Commit e12d381

Browse files
committed
Polish Windows installer output
1 parent 925776f commit e12d381

1 file changed

Lines changed: 41 additions & 17 deletions

File tree

install-windows.ps1

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,19 @@ function Wait-BeforeExit {
5656
}
5757
}
5858

59+
function Write-SummaryLine {
60+
param(
61+
[Parameter(Mandatory = $true)]
62+
[string]$Label,
63+
64+
[Parameter(Mandatory = $true)]
65+
[string]$Value
66+
)
67+
68+
Write-Host (" {0,-12}" -f $Label) -ForegroundColor Cyan -NoNewline
69+
Write-Host " $Value"
70+
}
71+
5972
function Format-CommandForDisplay {
6073
param(
6174
[Parameter(Mandatory = $true)]
@@ -91,8 +104,22 @@ function Invoke-NativeCommand {
91104
)
92105

93106
Write-Host ("Running: {0}" -f (Format-CommandForDisplay -FilePath $FilePath -Arguments $Arguments)) -ForegroundColor DarkGray
94-
$output = & $FilePath @Arguments 2>&1
95-
$exitCode = $LASTEXITCODE
107+
108+
$hadNativePreference = Test-Path variable:PSNativeCommandUseErrorActionPreference
109+
if ($hadNativePreference) {
110+
$previousNativePreference = $PSNativeCommandUseErrorActionPreference
111+
$PSNativeCommandUseErrorActionPreference = $false
112+
}
113+
114+
try {
115+
$output = & $FilePath @Arguments 2>&1
116+
$exitCode = $LASTEXITCODE
117+
}
118+
finally {
119+
if ($hadNativePreference) {
120+
$PSNativeCommandUseErrorActionPreference = $previousNativePreference
121+
}
122+
}
96123

97124
if ($output) {
98125
foreach ($line in @($output)) {
@@ -208,7 +235,6 @@ then run this installer again.
208235
$venvPython = Join-Path $ScriptsDir 'python.exe'
209236

210237
Log 'Installing / upgrading Slicer URI Bridge'
211-
Invoke-NativeCommand -FilePath $venvPython -Arguments @('-m', 'pip', 'install', '--upgrade', 'pip') -FailureMessage 'Failed to upgrade pip.' | Out-Null
212238
Invoke-NativeCommand -FilePath $venvPython -Arguments @('-m', 'pip', 'install', '--upgrade', $ProjectSpec) -FailureMessage 'pip install failed.' | Out-Null
213239

214240
Log 'Adding Scripts directory to user PATH'
@@ -228,20 +254,18 @@ then run this installer again.
228254

229255
$configDir = Join-Path $env:APPDATA 'slicer-uri-bridge'
230256

231-
Write-Host @"
232-
233-
Done! Slicer URI Bridge is installed.
234-
235-
Command: slicer-uri-bridge
236-
Config: $configDir\config.toml
237-
Logs: $configDir\bridge.log
238-
Test: slicer-uri-bridge test
239-
Environment: $VenvDir
240-
241-
If "slicer-uri-bridge" is not found, open a new terminal window.
242-
To update later, just run this installer again.
243-
244-
"@
257+
Write-Host ''
258+
Write-Host 'Done! Slicer URI Bridge is installed.' -ForegroundColor Green
259+
Write-Host ''
260+
Write-SummaryLine -Label 'Command:' -Value 'slicer-uri-bridge'
261+
Write-SummaryLine -Label 'Config:' -Value "$configDir\config.toml"
262+
Write-SummaryLine -Label 'Logs:' -Value "$configDir\bridge.log"
263+
Write-SummaryLine -Label 'Test:' -Value 'slicer-uri-bridge test'
264+
Write-SummaryLine -Label 'Environment:' -Value $VenvDir
265+
Write-Host ''
266+
Write-Host ' If "slicer-uri-bridge" is not found, open a new terminal window.' -ForegroundColor DarkGray
267+
Write-Host ' To update later, just run this installer again.' -ForegroundColor DarkGray
268+
Write-Host ''
245269
}
246270

247271
try {

0 commit comments

Comments
 (0)