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

Add function(s) for getting common game directories #8

Open
devynspencer opened this issue Aug 23, 2022 · 3 comments
Open

Add function(s) for getting common game directories #8

devynspencer opened this issue Aug 23, 2022 · 3 comments

Comments

@devynspencer
Copy link
Owner

Add another quality of life function to get frequently needed directories for modding:

image

image

@devynspencer
Copy link
Owner Author

Parameter Sets and Reusable Modifier Parameters

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.

Parent Location Parameters

Add parameter sets that narrow the context into a major area, specified by a -Context or -Scope parameter:

  • Steam (or Game)
  • Media
  • User
  • Mods
  • Development
  • Server

Child Location Parameters

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.

Examples

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.

@devynspencer
Copy link
Owner Author

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.

@devynspencer
Copy link
Owner Author

Combining an ArgumentCompleter attribute with a ValidateScript attribute. This adds minor code duplication but supports the desired tab-completion.

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

No branches or pull requests

1 participant