2021-05-19 07:51:30 +02:00
|
|
|
|
<#
|
2021-07-13 21:10:02 +02:00
|
|
|
|
.SYNOPSIS
|
|
|
|
|
what-is.ps1 [<abbreviation>]
|
|
|
|
|
.DESCRIPTION
|
|
|
|
|
Prints a description of the given abbreviation
|
|
|
|
|
.EXAMPLE
|
|
|
|
|
PS> .\what-is.ps1 CIA
|
|
|
|
|
.LINK
|
|
|
|
|
https://github.com/fleschutz/PowerShell
|
|
|
|
|
.NOTES
|
2021-08-03 15:53:57 +02:00
|
|
|
|
Author: Markus Fleschutz
|
|
|
|
|
License: CC0
|
2021-04-27 15:54:52 +02:00
|
|
|
|
#>
|
|
|
|
|
|
2021-07-15 15:51:22 +02:00
|
|
|
|
param([string]$Abbreviation = "")
|
2021-04-27 15:54:52 +02:00
|
|
|
|
|
|
|
|
|
try {
|
2021-07-15 15:51:22 +02:00
|
|
|
|
if ($Abbreviation -eq "" ) { $Abbreviation = read-host "Enter the abbreviation" }
|
|
|
|
|
|
2021-04-29 20:19:07 +02:00
|
|
|
|
write-progress "Searching ..."
|
|
|
|
|
|
2021-05-20 11:30:01 +02:00
|
|
|
|
$FoundOne = $false
|
|
|
|
|
$Files = (get-childItem "$PSScriptRoot/../Data/Abbr/*" -attributes !Directory)
|
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) {
|
2021-05-25 17:51:46 +02:00
|
|
|
|
if ($Row.Abbreviation -eq $Abbreviation) {
|
2021-05-25 19:42:11 +02:00
|
|
|
|
$Basename = (get-item "$File").Basename
|
|
|
|
|
" → $($Row.Abbreviation) = $($Row.Definition) in $Basename"
|
2021-05-20 11:30:01 +02:00
|
|
|
|
$FoundOne = $true
|
|
|
|
|
}
|
2021-04-27 15:54:52 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-20 11:30:01 +02:00
|
|
|
|
if ($FoundOne -eq $false) { "Sorry, no entry for $Abbreviation found" }
|
2021-04-27 15:54:52 +02:00
|
|
|
|
exit 0
|
|
|
|
|
} catch {
|
2021-05-02 21:30:48 +02:00
|
|
|
|
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
2021-04-27 15:54:52 +02:00
|
|
|
|
exit 1
|
|
|
|
|
}
|