Skip to content

Commit b71c18b

Browse files
Enhance compilerHelper.ps1 to support auto-accept and file selection for compilation in the cmd line itself
1 parent 2072474 commit b71c18b

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

tool/compilerHelper.ps1

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,34 @@ if (-not $cFiles) {
2525
exit 1
2626
}
2727

28-
# Prompt user for each detected .c file whether to compile it
28+
# Handle -y and file arguments for auto-accept and selection
29+
$acceptAll = $false
30+
$specifiedFiles = @()
31+
foreach ($arg in $args) {
32+
if ($arg -eq "-y") {
33+
$acceptAll = $true
34+
} elseif ($arg -like "*.c") {
35+
$specifiedFiles += $arg
36+
}
37+
}
38+
2939
$filesToCompile = @()
30-
foreach ($file in $cFiles) {
31-
$answer = Read-Host "Compile '$file'? (Y/N, default N)"
32-
if ($answer -match '^(y|Y)$') {
33-
$filesToCompile += $file
40+
if ($specifiedFiles.Count -gt 0) {
41+
foreach ($file in $specifiedFiles) {
42+
if ($cFiles -contains $file) {
43+
$filesToCompile += $file
44+
} else {
45+
Write-CustomError "Specified file not found: $file"
46+
}
47+
}
48+
} elseif ($acceptAll) {
49+
$filesToCompile = $cFiles
50+
} else {
51+
foreach ($file in $cFiles) {
52+
$answer = Read-Host "Compile '$file'? (Y/N, default N)"
53+
if ($answer -match '^(y|Y)$') {
54+
$filesToCompile += $file
55+
}
3456
}
3557
}
3658

0 commit comments

Comments
 (0)