feat: allow replacements in startup command #259
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, when you use the replacement syntax
{}in the startup command, it isn't replaced. Since I was hoping to use this as an argument that can't be passed with a space delimiting it, I needed to introduce a separatereplacerwhich uses theaho-corasickalgorithm to replace instances of the string. I included tests for the replacer and another test to assert the existing behaviour for preview commands.This PR was made specifically to introduce the least change, but my preference (if you're happy with it) is to instead use the new
Replacerto complete replacements inPrepareCmdbefore splitting and substituting the home directory. This way we have a consistent replacement mechanism. I'm also open to the replacement mechanism being used for home directory substitution as well, withPrepareCmdonly being used to split into a string array. This would change behaviour, however, which I wasn't 100% on!