Add OpenRPC method for evaluating a when
clause
#4165
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.
Goes along with posit-dev/ark#449
I was thinking about how to address #2697 and have a proposed approach in this PR plus the accompanying PR for ark. I looked at how various extensions (like the git extension, etc) check for whether we are in a git repo in the workspace and all that checking is typically based on context keys. In an extension specifically, you can check those keys with a "when" clause and I realized that approach (i.e. a string) could work well as an OpenRPC method and would be flexible for other context keys we will need to check when we are not in the main thread.
Alternatively, we could add methods to return more specific info (are we in a git repo? etc etc etc) but I like the idea of using "when" clauses for this, like an extension could directly for commands, etc.
QA Notes
Evaluating code like this in R should show the correct results for your situation: