2021-09-27 10:38:12 +02:00
|
|
|
|
<#
|
2021-07-13 21:10:02 +02:00
|
|
|
|
.SYNOPSIS
|
2021-10-16 16:50:10 +02:00
|
|
|
|
Prints a description of an abbreviation
|
2021-07-13 21:10:02 +02:00
|
|
|
|
.DESCRIPTION
|
2022-01-30 10:49:30 +01:00
|
|
|
|
This PowerShell script prints a description of the given abbreviation.
|
2021-10-16 16:50:10 +02:00
|
|
|
|
.PARAMETER abbreviation
|
|
|
|
|
Specifies the appreviation 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
|
|
|
|
|
Author: Markus Fleschutz / License: CC0
|
2021-04-27 15:54:52 +02:00
|
|
|
|
#>
|
|
|
|
|
|
2021-08-29 17:50:03 +02:00
|
|
|
|
param([string]$abbreviation = "")
|
2021-04-27 15:54:52 +02:00
|
|
|
|
|
2021-11-28 11:57:49 +01:00
|
|
|
|
function Reply { param([string]$Text)
|
2021-12-06 17:00:49 +01:00
|
|
|
|
& "$PSScriptRoot/give-reply.ps1" "$Text"
|
2021-11-28 11:57:49 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-27 15:54:52 +02:00
|
|
|
|
try {
|
2021-08-29 17:50:03 +02:00
|
|
|
|
if ($abbreviation -eq "" ) { $abbreviation = read-host "Enter the abbreviation" }
|
2021-07-15 15:51:22 +02:00
|
|
|
|
|
2021-05-20 11:30:01 +02:00
|
|
|
|
$FoundOne = $false
|
2021-11-28 11:57:49 +01:00
|
|
|
|
$Files = (get-childItem "$PSScriptRoot/../Data/Abbr/*.csv")
|
2021-04-29 20:19:07 +02:00
|
|
|
|
|
2021-05-20 11:30:01 +02:00
|
|
|
|
foreach ($File in $Files) {
|
|
|
|
|
$Table = import-csv "$File"
|
|
|
|
|
foreach($Row in $Table) {
|
2022-01-27 07:28:19 +01:00
|
|
|
|
if ($Row.Abbr -eq $abbreviation) {
|
2021-05-25 19:42:11 +02:00
|
|
|
|
$Basename = (get-item "$File").Basename
|
2022-01-27 07:28:19 +01:00
|
|
|
|
Reply "In $Basename $($Row.Abbr) may refer to $($Row.Term)"
|
2021-05-20 11:30:01 +02:00
|
|
|
|
$FoundOne = $true
|
|
|
|
|
}
|
2021-04-27 15:54:52 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-06 13:27:12 +01:00
|
|
|
|
if ($FoundOne -eq $false) { Reply "Sorry, no database entry found." }
|
2021-09-27 10:09:45 +02:00
|
|
|
|
exit 0 # success
|
2021-04-27 15:54:52 +02:00
|
|
|
|
} catch {
|
2021-09-16 20:19:10 +02:00
|
|
|
|
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
2021-04-27 15:54:52 +02:00
|
|
|
|
exit 1
|
|
|
|
|
}
|