Update what-is.ps1

This commit is contained in:
Markus Fleschutz 2023-08-18 19:07:48 +02:00
parent 772fdb2b68
commit 6d75ce1ec5
2 changed files with 14 additions and 17 deletions

View File

@ -4867,7 +4867,6 @@ VSR,Very Special Relativity
VT,Vatican City-State (FIPS 10-4 country code),Vermont (postal symbol),Video tape,Virginia Tech
VTC,Video Tele-Conference
VTEC,Variable valve Timing and Electronic lift Control
VTOL,Vertical Take-Off & Landing
VU,Vanuatu (ISO 3166 digram),Vedanta University
VUB,Vrije Universiteit Brussel (Belgian university)
VUT,Vanuatu (ISO 3166 trigram)

Can't render this file because it has a wrong number of fields in line 7.

View File

@ -2,11 +2,12 @@
.SYNOPSIS
Explains an abbreviation
.DESCRIPTION
This PowerShell script queries the description of the given abbreviation and prints it.
This PowerShell script queries the meaning of the given abbreviation and prints it.
.PARAMETER abbr
Specifies the abbreviation to look for
Specifies the abbreviation to query
.EXAMPLE
PS> ./what-is IAS
PS> ./what-is VTOL
💡 VTOL in aviation refers to: Vertical Take-Off and Landing
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
@ -16,21 +17,18 @@
param([string]$abbr = "")
try {
if ($abbr -eq "" ) { $abbr = Read-Host "Enter the abbreviation" }
$Files = (Get-ChildItem "$PSScriptRoot/../Data/Abbr/*.csv")
[int]$Matches = 0
foreach($File in $Files) {
$Table = Import-CSV "$File"
foreach($Row in $Table) {
if ($Row.ABBR -eq $abbr) {
$Basename = (Get-Item "$File").Basename -Replace "_"," "
"💡 $($Row.ABBR) in $Basename refers to: $($Row.MEANING)"
$Matches++
}
if ($abbr -eq "" ) { $abbr = Read-Host "Enter the abbreviation to query" }
$files = (Get-ChildItem "$PSScriptRoot/../Data/Abbr/*.csv")
$basename = ""
foreach($file in $files) {
$table = Import-CSV "$file"
foreach($row in $table) {
if ($row.ABBR -ne $abbr) { continue }
$basename = (Get-Item "$file").Basename -Replace "_"," "
"💡 $($row.ABBR) in $basename refers to: $($row.MEANING)"
}
}
if ($Matches -eq 0) { "Sorry, '$abbr' is missing in the database." }
if ($basename -eq "") { "🤷‍ Sorry, my databases have no '$abbr' entry." }
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"