Closed jdhitsolutions closed 1 year ago
One potential drawback to storing preferences in the database is the need to update the database table. On the other hand, separating data from formatting seems like a standard practice.
Leaning towards code like this to keep preferences separate from data.
#create a command called Update-PSWorkItemPreferences
$pref = [PSCustomObject]@{
Path = $PSWorkItemPath
Categories = $PSWorkItemCategory.GetEnumerator() | ForEach-Object { @{Category = $_.Key;ANSI = $_.value}}
}
$pref | ConvertTo-Json | Out-File C:\temp\pref.json
#on module import, test for preference file and import it if found
$importPref = Get-Content c:\temp\pref.json | ConvertFrom-Json
$PSWorkItemPath = $importPref.Path
$importPref.categories.foreach({$PSWorkItemCategory[$_.category]=$_.ansi})
#otherwise, use defaults or profile-driven settings
Version 1.1.0 will introduce a file preferences file stored in $HOME.
I am debating ways to store user preferences, like the path, additional categories, and category color schemes. This could be part of the database. But in a shared database situation, some users may have different color preferences. Thinking about storing a JSON file in $HOME that would be used on module import, if found. Would need to add commands to create or update the file. Open to other suggestions that will work cross-platform.