Open devynspencer opened 2 years ago
After a moment of thought, the above is a good candidate for refactoring the just added Get-ZomboidModLocation
function. The function could be renamed to a more general Get-ZomboidLocation
or similar, and have additional switch parameters for major parent directories.
Add parameter sets that narrow the context into a major area, specified by a -Context
or -Scope
parameter:
To support the above (and to avoid 50+ switch parameters), the above are augmented with a common -Name
or -LocationName
parameter for specifying the children of the above.
The Name
parameters would be reusable, as in each parameter set would have a different set of values for the ValidateSet
attribute. This avoids needing a tons of flags while also providing auto-completion for tabbing through potential values.
The "Mods" value for these two commands would be different, as they refer to the mods directory for the User and Steam directories, respectively:
Get-ZomboidLocation -Context User -Name Mods
Get-ZomboidLocation -Context Steam -Name Mods
Furthermore, discovery is possible so a fledgling modder can easily begin to understand the important locations within the user Zomboid directory (and consistently reference these locations from scripts):
Get-ZomboidLocation -Context User -Name Logs, Lua, SandboxPresets
This isn't necessary by any means, but anything that removes a barrier to development or troubleshooting is a very good thing. Worst case this is something that would likely be refactored into a private function anyways. Making the function easy to use on the shell as well is just a bonus.
Oof, it turns out that multiple ValidateSet
attributes cannot be applied to a parameter (as it's not designated in the Parameter
attribute where ParameterSetName
is specified.
It may be worth looking into dynamic parameter sets, but the alternative would appear to be a parameter for locations from each context.
Combining an ArgumentCompleter
attribute with a ValidateScript
attribute. This adds minor code duplication but supports the desired tab-completion.
Add another quality of life function to get frequently needed directories for modding: