2021-09-27 10:38:12 +02:00
|
|
|
|
<#
|
2021-07-13 21:10:02 +02:00
|
|
|
|
.SYNOPSIS
|
2023-03-28 11:24:49 +02:00
|
|
|
|
Explains an abbreviation
|
2021-07-13 21:10:02 +02:00
|
|
|
|
.DESCRIPTION
|
2023-03-28 11:24:49 +02:00
|
|
|
|
This PowerShell script queries the description of the given abbreviation and prints it.
|
2022-12-21 08:14:30 +01:00
|
|
|
|
.PARAMETER abbr
|
|
|
|
|
Specifies the abbreviation to look for
|
2021-07-13 21:10:02 +02:00
|
|
|
|
.EXAMPLE
|
2021-11-28 11:57:49 +01:00
|
|
|
|
PS> ./what-is IAS
|
2021-07-13 21:10:02 +02:00
|
|
|
|
.LINK
|
|
|
|
|
https://github.com/fleschutz/PowerShell
|
2022-01-30 10:49:30 +01:00
|
|
|
|
.NOTES
|
2022-09-06 21:42:04 +02:00
|
|
|
|
Author: Markus Fleschutz | License: CC0
|
2021-04-27 15:54:52 +02:00
|
|
|
|
#>
|
|
|
|
|
|
2022-12-21 08:14:30 +01:00
|
|
|
|
param([string]$abbr = "")
|
2021-11-28 11:57:49 +01:00
|
|
|
|
|
2021-04-27 15:54:52 +02:00
|
|
|
|
try {
|
2022-12-21 08:14:30 +01:00
|
|
|
|
if ($abbr -eq "" ) { $abbr = Read-Host "Enter the abbreviation" }
|
2021-04-29 20:19:07 +02:00
|
|
|
|
|
2022-12-21 08:14:30 +01:00
|
|
|
|
$Files = (Get-ChildItem "$PSScriptRoot/../Data/Abbr/*.csv")
|
2023-03-28 11:24:49 +02:00
|
|
|
|
[int]$Matches = 0
|
|
|
|
|
foreach($File in $Files) {
|
2022-12-21 08:14:30 +01:00
|
|
|
|
$Table = Import-CSV "$File"
|
2021-05-20 11:30:01 +02:00
|
|
|
|
foreach($Row in $Table) {
|
2023-02-17 14:44:58 +01:00
|
|
|
|
if ($Row.ABBR -eq $abbr) {
|
2023-01-02 16:24:29 +01:00
|
|
|
|
$Basename = (Get-Item "$File").Basename -Replace "_"," "
|
2023-04-25 16:26:58 +02:00
|
|
|
|
"💡 $($Row.ABBR) in $Basename refers to: $($Row.TERM)"
|
2023-03-28 11:24:49 +02:00
|
|
|
|
$Matches++
|
2021-05-20 11:30:01 +02:00
|
|
|
|
}
|
2021-04-27 15:54:52 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-03-28 11:24:49 +02:00
|
|
|
|
if ($Matches -eq 0) { "Sorry, '$abbr' is missing in the database." }
|
2021-09-27 10:09:45 +02:00
|
|
|
|
exit 0 # success
|
2021-04-27 15:54:52 +02:00
|
|
|
|
} catch {
|
2022-04-13 12:06:32 +02:00
|
|
|
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
2021-04-27 15:54:52 +02:00
|
|
|
|
exit 1
|
2023-02-17 14:44:58 +01:00
|
|
|
|
}
|