smileyface/edit-config-windows.ps1

39 lines
1.0 KiB
PowerShell
Raw Permalink Normal View History

2021-08-18 21:47:27 -06:00
# Opens hie_parser configuration file in the default editor, creating file
# if necessary.
$config_filepath = Join-Path -Path "$env:USERPROFILE" -ChildPath "\AppData\Local\smileyface-ut4\hub_config.ini"
$dir_path = Split-Path -Path "$config_filepath"
# Create config directory if necessary:
if (!(Test-Path "$dir_path" -Type Container))
{
Write-Host "Creating config directory: $dir_path"
New-Item -ItemType "directory" -Path "$dir_path" > $null
Write-Host
}
# Create config.ini if necessary:
if (!(Test-Path "$config_filepath" -Type Leaf))
{
Write-Host "Creating new config.ini: $config_filepath"
New-Item -Path "$config_filepath" > $null
Set-Content "$config_filepath" @"
"@
}
# Open config.ini in favorite text editor:
Write-Host "Opening covid_parser configuration in your system-default editor"
Write-Host "Configuration file: $config_filepath"
Invoke-Item "$config_filepath"
# Leave terminal open after done:
if ($Host.Name -eq "ConsoleHost")
{
Write-Host "Done."
$host.UI.RawUI.ReadKey("NoEcho,IncludeKeyUp") > $null
}