Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Storing User Preferences #10

Closed
jdhitsolutions opened this issue Jun 29, 2023 · 3 comments
Closed

Storing User Preferences #10

jdhitsolutions opened this issue Jun 29, 2023 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@jdhitsolutions
Copy link
Owner

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.

@jdhitsolutions jdhitsolutions self-assigned this Jun 29, 2023
@jdhitsolutions jdhitsolutions added the enhancement New feature or request label Jun 29, 2023
@jdhitsolutions
Copy link
Owner Author

jdhitsolutions commented Jun 29, 2023

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.

@jdhitsolutions
Copy link
Owner Author

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

@jdhitsolutions
Copy link
Owner Author

Version 1.1.0 will introduce a file preferences file stored in $HOME.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant