diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-07-02 14:57:31 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-07-02 14:57:31 +0800 |
| commit | 1eb45c9c4afc631cfc97dd78ada1ab797627dec4 (patch) | |
| tree | fe4e925e682b17e20ac6bae0edbfcb4a0e4289b1 | |
| parent | 0c1a2d15f119bf4c11303ff9aecc9e69a6b3a2ad (diff) | |
feat: add support for running binary executables
Add detection and execution of standalone binary files (without
extensions in shell, with .exe in PowerShell) to the tool runner
| -rw-r--r-- | run.ps1 | 10 | ||||
| -rw-r--r-- | run.sh | 14 |
2 files changed, 24 insertions, 0 deletions
@@ -26,6 +26,12 @@ if (Test-Path ".run/src/bin/*.ps1") { } } +if (Test-Path ".run/src/bin/*.exe") { + Get-ChildItem -Path ".run/src/bin/*.exe" | ForEach-Object { + $tools[$_.BaseName] = @{ Type = "exe"; Path = $_.FullName } + } +} + if ($args.Count -eq 0) { $sorted = $tools.Keys | Sort-Object $total = $sorted.Count @@ -53,6 +59,7 @@ if ($args.Count -eq 0) { "py" { "Python" } "rs" { "Rust" } "ps1" { "PowerShell" } + "exe" { "Binary" } } $entry = " " + $i.ToString().PadRight($num_w) + ") " + $name.PadRight($max_name) + " [$lang]" Write-Host ("│" + $entry.PadRight($inner_w) + "│") @@ -89,6 +96,9 @@ switch ($info.Type) { "ps1" { & $info.Path @script_args } + "exe" { + & $info.Path $script_args + } "py" { python $info.Path $script_args } @@ -32,6 +32,15 @@ for file in .run/src/bin/*.sh; do fi done +for file in .run/src/bin/*; do + if [ -f "$file" ]; then + name=$(basename "$file") + if [[ ! "$name" == *.* ]]; then + tools["$name"]="binary" + fi + fi +done + if [ $# -eq 0 ]; then sorted_names=($(echo "${!tools[@]}" | tr ' ' '\n' | sort)) total=${#sorted_names[@]} @@ -63,6 +72,7 @@ if [ $# -eq 0 ]; then py) lang="Python";; rs) lang="Rust";; sh) lang="Shell";; + binary) lang="Binary";; esac entry=$(printf " %-*d) %-*s [%s]" $num_w $i $max_name $name $lang) printf "│%-*s│\n" $inner_w "$entry" @@ -145,4 +155,8 @@ CSPROJ cp ".run/src/bin/$target_name.cs" "$temp_dir/Program.cs" dotnet run --project "$temp_dir/$target_name.csproj" -- "$@" ;; + binary) + chmod +x ".run/src/bin/$target_name" + ".run/src/bin/$target_name" "$@" + ;; esac |
