Use Write-Host instead of echo

This commit is contained in:
teinarss
2019-05-11 12:52:35 +02:00
committed by reaperrr
parent e888a235c0
commit 70f0075415

View File

@@ -15,11 +15,11 @@ function All-Command
dotnet build /p:Configuration=Release /nologo dotnet build /p:Configuration=Release /nologo
if ($lastexitcode -ne 0) if ($lastexitcode -ne 0)
{ {
echo "Build failed. If just the development tools failed to build, try installing Visual Studio. You may also still be able to run the game." Write-Host "Build failed. If just the development tools failed to build, try installing Visual Studio. You may also still be able to run the game." -ForegroundColor Red
} }
else else
{ {
echo "Build succeeded." Write-Host "Build succeeded." -ForegroundColor Green
} }
} }
@@ -43,7 +43,7 @@ function Clean-Command
{ {
rmdir thirdparty/download -Recurse -Force rmdir thirdparty/download -Recurse -Force
} }
echo "Clean complete." Write-Host "Clean complete." -ForegroundColor Green
} }
function Version-Command function Version-Command
@@ -65,12 +65,12 @@ function Version-Command
} }
else else
{ {
echo "Not a git repository. The version will remain unchanged." Write-Host "Not a git repository. The version will remain unchanged." -ForegroundColor Red
} }
} }
else else
{ {
echo "Unable to locate Git. The version will remain unchanged." Write-Host "Unable to locate Git. The version will remain unchanged." -ForegroundColor Red
} }
if ($version -ne $null) if ($version -ne $null)
@@ -90,7 +90,7 @@ function Version-Command
$replacement = (gc $mod) -Replace ".*: User", ("{0}/{1}: User" -f $prefix, $version) $replacement = (gc $mod) -Replace ".*: User", ("{0}/{1}: User" -f $prefix, $version)
sc $mod $replacement sc $mod $replacement
} }
echo ("Version strings set to '{0}'." -f $version) Write-Host ("Version strings set to '{0}'." -f $version)
} }
} }
@@ -102,7 +102,7 @@ function Dependencies-Command
cp download/GeoLite2-Country.mmdb.gz .. cp download/GeoLite2-Country.mmdb.gz ..
cp download/windows/*.dll .. cp download/windows/*.dll ..
cd .. cd ..
echo "Dependencies copied." Write-Host "Dependencies copied." -ForegroundColor Cyan
if ((CheckForDotnet) -eq 1) if ((CheckForDotnet) -eq 1)
{ {
@@ -112,7 +112,7 @@ function Dependencies-Command
dotnet restore /nologo dotnet restore /nologo
if ($lastexitcode -ne 0) if ($lastexitcode -ne 0)
{ {
echo "Project restoration failed." Write-Host "Project restoration failed." -ForegroundColor Red
} }
} }
@@ -123,29 +123,29 @@ function Test-Command
return return
} }
echo "Testing mods..." Write-Host "Testing mods..." -ForegroundColor Cyan
echo "Testing Tiberian Sun mod MiniYAML..." Write-Host "Testing Tiberian Sun mod MiniYAML..." -ForegroundColor Cyan
./OpenRA.Utility.exe ts --check-yaml ./OpenRA.Utility.exe ts --check-yaml
echo "Testing Dune 2000 mod MiniYAML..." Write-Host "Testing Dune 2000 mod MiniYAML..." -ForegroundColor Cyan
./OpenRA.Utility.exe d2k --check-yaml ./OpenRA.Utility.exe d2k --check-yaml
echo "Testing Tiberian Dawn mod MiniYAML..." Write-Host "Testing Tiberian Dawn mod MiniYAML..." -ForegroundColor Cyan
./OpenRA.Utility.exe cnc --check-yaml ./OpenRA.Utility.exe cnc --check-yaml
echo "Testing Red Alert mod MiniYAML..." Write-Host "Testing Red Alert mod MiniYAML..." -ForegroundColor Cyan
./OpenRA.Utility.exe ra --check-yaml ./OpenRA.Utility.exe ra --check-yaml
} }
function Check-Command function Check-Command
{ {
echo "Compiling in debug configuration..." Write-Host "Compiling in debug configuration..." -ForegroundColor Cyan
dotnet build /p:Configuration=Debug /nologo dotnet build /p:Configuration=Debug /nologo
if ($lastexitcode -ne 0) if ($lastexitcode -ne 0)
{ {
echo "Build failed." Write-Host "Build failed." -ForegroundColor Red
} }
if ((CheckForUtility) -eq 0) if ((CheckForUtility) -eq 0)
{ {
echo "Checking for explicit interface violations..." Write-Host "Checking for explicit interface violations..." -ForegroundColor Cyan
./OpenRA.Utility.exe all --check-explicit-interfaces ./OpenRA.Utility.exe all --check-explicit-interfaces
} }
} }
@@ -154,7 +154,7 @@ function Check-Scripts-Command
{ {
if ((Get-Command "luac.exe" -ErrorAction SilentlyContinue) -ne $null) if ((Get-Command "luac.exe" -ErrorAction SilentlyContinue) -ne $null)
{ {
echo "Testing Lua scripts..." Write-Host "Testing Lua scripts..." -ForegroundColor Cyan
foreach ($script in ls "mods/*/maps/*/*.lua") foreach ($script in ls "mods/*/maps/*/*.lua")
{ {
luac -p $script luac -p $script
@@ -163,11 +163,11 @@ function Check-Scripts-Command
{ {
luac -p $script luac -p $script
} }
echo "Check completed!" Write-Host "Check completed!" -ForegroundColor Green
} }
else else
{ {
echo "luac.exe could not be found. Please install Lua." Write-Host "luac.exe could not be found. Please install Lua." -ForegroundColor Red
} }
} }
@@ -192,7 +192,7 @@ function CheckForUtility
return 0 return 0
} }
echo "OpenRA.Utility.exe could not be found. Build the project first using the `"all`" command." Write-Host "OpenRA.Utility.exe could not be found. Build the project first using the `"all`" command." -ForegroundColor Red
return 1 return 1
} }
@@ -200,7 +200,7 @@ function CheckForDotnet
{ {
if ((Get-Command "dotnet" -ErrorAction SilentlyContinue) -eq $null) if ((Get-Command "dotnet" -ErrorAction SilentlyContinue) -eq $null)
{ {
echo "The 'dotnet' tool is required to compile OpenRA. Please install the .NET Core SDK or Visual studio and try again." Write-Host "The 'dotnet' tool is required to compile OpenRA. Please install the .NET Core SDK or Visual Studio and try again. https://dotnet.microsoft.com/download" -ForegroundColor Red
return 1 return 1
} }
@@ -209,7 +209,7 @@ function CheckForDotnet
function WaitForInput function WaitForInput
{ {
echo "Press enter to continue." Write-Host "Press enter to continue."
while ($true) while ($true)
{ {
if ([System.Console]::KeyAvailable) if ([System.Console]::KeyAvailable)
@@ -225,26 +225,26 @@ function WaitForInput
############################################################### ###############################################################
if ($PSVersionTable.PSVersion.Major -clt 3) if ($PSVersionTable.PSVersion.Major -clt 3)
{ {
echo "The makefile requires PowerShell version 3 or higher." Write-Host "The makefile requires PowerShell version 3 or higher." -ForegroundColor Red
echo "Please download and install the latest Windows Management Framework version from Microsoft." Write-Host "Please download and install the latest Windows Management Framework version from Microsoft." -ForegroundColor Red
WaitForInput WaitForInput
} }
if ($args.Length -eq 0) if ($args.Length -eq 0)
{ {
echo "Command list:" Write-Host "Command list:"
echo "" Write-Host ""
echo " all, a Builds the game and its development tools." Write-Host " all, a Builds the game and its development tools."
echo " dependencies, d Copies the game's dependencies into the main game folder." Write-Host " dependencies, d Copies the game's dependencies into the main game folder."
echo " version, v Sets the version strings for the default mods to the" Write-Host " version, v Sets the version strings for the default mods to the"
echo " latest version for the current Git branch." Write-Host " latest version for the current Git branch."
echo " clean, c Removes all built and copied files. Use the 'all' and" Write-Host " clean, c Removes all built and copied files. Use the 'all' and"
echo " 'dependencies' commands to restore removed files." Write-Host " 'dependencies' commands to restore removed files."
echo " test, t Tests the default mods for errors." Write-Host " test, t Tests the default mods for errors."
echo " check, ck Checks .cs files for StyleCop violations." Write-Host " check, ck Checks .cs files for StyleCop violations."
echo " check-scripts, cs Checks .lua files for syntax errors." Write-Host " check-scripts, cs Checks .lua files for syntax errors."
echo " docs Generates the trait and Lua API documentation." Write-Host " docs Generates the trait and Lua API documentation."
echo "" Write-Host ""
$command = (Read-Host "Enter command").Split(' ', 2) $command = (Read-Host "Enter command").Split(' ', 2)
} }
else else
@@ -268,7 +268,7 @@ switch ($execute)
{"check", "ck" -contains $_} { Check-Command } {"check", "ck" -contains $_} { Check-Command }
{"check-scripts", "cs" -contains $_} { Check-Scripts-Command } {"check-scripts", "cs" -contains $_} { Check-Scripts-Command }
"docs" { Docs-Command } "docs" { Docs-Command }
Default { echo ("Invalid command '{0}'" -f $command) } Default { Write-Host ("Invalid command '{0}'" -f $command) }
} }
#In case the script was called without any parameters we keep the window open #In case the script was called without any parameters we keep the window open