File tree Expand file tree Collapse file tree 1 file changed +27
-5
lines changed Expand file tree Collapse file tree 1 file changed +27
-5
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments