-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.ps1
76 lines (64 loc) · 2.75 KB
/
run.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Lint, build the ressource file and run the app
$ErrorActionPreference = 'Stop'
function Start-ModeS($arguments) {
Write-Host ("run.ps1 $arguments`n") -ForegroundColor DarkGray
if ("-t" -notin $arguments -and "-i" -notin $arguments) {
$qmlFiles = Get-ChildItem .\src\gui\* -Recurse -Include *.qml, *.js | Select-Object -ExpandProperty FullName
$ressourcesFile = "$(Get-Item .\src\gui\gui.qrc)"
Write-Host ("# Linting QML...") -ForegroundColor Cyan -NoNewline
$qmllint = Get-Command qmllint.exe -ErrorAction SilentlyContinue
if ($qmllint) {
. $qmllint $qmlFiles
if ($LASTEXITCODE -eq 0) {
Write-Host ("`t`tDone.") -ForegroundColor Green
}
else {
Write-Host ("`t`tWarnings`n|-> Last exit code: $LASTEXITCODE") -ForegroundColor DarkYellow
}
}
else {
Write-Host ("`t`tSkipped`n|-> Cannot find qmllint.exe") -ForegroundColor DarkYellow
}
Write-Host ("# Building Ressources...") -ForegroundColor Cyan -NoNewline
$pyside2_rcc = Get-Command pyside2-rcc.exe -ErrorAction SilentlyContinue
if ($pyside2_rcc) {
. $pyside2_rcc $ressourcesFile -o "$(Get-Location)\src\gui\qrc_gui.py"
if ($LASTEXITCODE -eq 0) {
Write-Host ("`tDone.") -ForegroundColor Green
}
else {
Write-Host ("`tWarnings`n|-> Last exit code: $LASTEXITCODE") -ForegroundColor DarkYellow
}
}
else {
Write-Host ("`tError`n|-> Cannot find pyside2_rcc.exe") -ForegroundColor Red
exit -1
}
if ("--no-start" -in $arguments) {
exit 0
}
}
if ("-v" -notin $arguments -and "-d" -notin $arguments) {
Write-Host ("# Starting the app...") -ForegroundColor Cyan -NoNewline
} else {
Write-Host ("# Starting the app...") -ForegroundColor Cyan
}
$app = Start-Process -FilePath "python" -ArgumentList "$(Get-Item .\src\app\main.py)", "$($arguments | Where-Object {$_ -ne "--loop"})" -WorkingDirectory "$(Get-Location)/src" -NoNewWindow -PassThru -Wait
if ($app.ExitCode -eq 0) {
Write-Host ("`t`tDone.") -ForegroundColor Green
} else {
Write-Host ("`t`tWarnings`n|-> Last exit code: $($app.ExitCode)") -ForegroundColor DarkYellow
}
}
if ("--loop" -in $args) {
while($True) {
$continue = Read-Host -Prompt "Press [enter] to continue or [n] to stop"
if ($continue -eq 'n') {break}
Clear-Host
Start-ModeS $args
}
} else {
Start-ModeS $args
}
Write-Host "Run.ps1 finished" -ForegroundColor DarkGray
exit $LASTEXITCODE