aboutsummaryrefslogtreecommitdiff
path: root/run.ps1
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-07-02 15:13:07 +0800
committer魏曹先生 <1992414357@qq.com>2026-07-02 15:13:07 +0800
commit68010bd9b4e3b39ad0306366a95c91ebd57eecf6 (patch)
treee6bf360a0258f898351c1a607c77ec35f1d5d28f /run.ps1
parentfa6dbd47c490c6ba14da46f6944ef32acccbdd02 (diff)
feat: add fuzzy target name matching and display name formatting
Normalize user input by removing separators (spaces, underscores, dots, hyphens) and ignore case when looking up targets. Display names in the list menu with spaces instead of underscores or hyphens for readability.
Diffstat (limited to 'run.ps1')
-rw-r--r--run.ps120
1 files changed, 17 insertions, 3 deletions
diff --git a/run.ps1 b/run.ps1
index 782fd46..f0c3652 100644
--- a/run.ps1
+++ b/run.ps1
@@ -96,7 +96,8 @@ if ($args.Count -eq 0) {
"nim" { "Nim" }
"exe" { "Binary" }
}
- $entry = " " + $i.ToString().PadRight($num_w) + ") " + $name.PadRight($max_name) + " [$lang]"
+ $displayName = $name -replace '[_\-]', ' '
+ $entry = " " + $i.ToString().PadRight($num_w) + ") " + $displayName.PadRight($max_name) + " [$lang]"
Write-Host ("│" + $entry.PadRight($inner_w) + "│")
$i++
}
@@ -120,8 +121,21 @@ if ($target_name -match '^\d+$') {
}
if (-not $tools.ContainsKey($target_name)) {
- Write-Host "Error: target '$target_name' does not exist"
- exit 1
+ $normalized = $target_name.ToLower() -replace '[ _\-\.]', ''
+ $found = $null
+ foreach ($key in $tools.Keys) {
+ $keyNormalized = $key.ToLower() -replace '[ _\-\.]', ''
+ if ($normalized -eq $keyNormalized) {
+ $found = $key
+ break
+ }
+ }
+ if ($found) {
+ $target_name = $found
+ } else {
+ Write-Host "Error: target '$target_name' does not exist"
+ exit 1
+ }
}
$script_args = $args[1..$args.Count]