utils.ps1
$Script:TableDirectory = "$Home/.envman" if (![System.IO.Directory]::Exists($Script:TableDirectory)) { New-Item -ItemType Directory -Force $Script:TableDirectory } function WriteTable ($Name, $Table) { $Lines = $Table.keys | ? { ![string]::IsNullOrEmpty($Table[$_]) } | % { "$_=$($Table[$_])" } ($Lines -join "`n") | Out-File "$Script:TableDirectory/$Name" } function LoadTable ($Name) { $Table = @{} (Get-Content "$Script:TableDirectory/$Name") | % { $entry = $_ -split '=' if ($null -ne $entry[1]) { $Table.Add($entry[0], $entry[1]) } } return $Table } function TableExists ($Name) { return [System.IO.File]::Exists("$Script:TableDirectory/$Name") } function ListTables { return Get-ChildItem $Script:TableDirectory | % { $_.Name } } function DeleteTable ($Name) { Remove-Item -Force "$Script:TableDirectory/$Name" } |