vscode-bazel
vscode-bazel copied to clipboard
Add "Run" command to binary targets in Codelens
trafficstars
Given a binary rule, for example
rust_binary(
name = "hello_word",
srcs = ["main.rs"],
)
there is no option to run this Bazel target in Codelens. Codelens only offers build for this target (see image)

It would be helpful to add the capability to run binary targets using Codelens.
This should be a fairly straightforward change. Here is the current code for adding Codelens commands: https://github.com/bazelbuild/vscode-bazel/blob/12c20773c5bbbdbbd30cc393c414622059c05537/src/codelens/bazel_build_code_lens_provider.ts#L116-L135
I think all we'd have to do is to conditionally add a run command for targets that end in _binary.
As an aside, it seems useful to add build and test for _test targets, so the code would end up more like:
// add build command
if (ruleClass.endsWith("_binary") {
// add run command
}
if (ruleClass.endsWith("_test") || ruleClass === "test_suite") {
// add test command
}