【发布时间】:2019-07-11 16:18:44
【问题描述】:
我正在尝试创建一个启动配置,其中环境变量由 shell 脚本动态确定。尽管command variable 可以通过workbench.action.tasks.runTask 启动任务,但似乎无法指定要运行的任务。 Input variables 在这方面似乎更灵活一些,但我似乎无法让它发挥作用。这是我得到的:
launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/main.go",
"env": {
"XXX": "${input:foo}"
},
"args": []
}
],
"inputs": [
{
"type": "command",
"id": "foo",
"command": "workbench.action.tasks.runTask",
"args": {
"args": "bar",
}
}
]
}
tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"label": "bar",
"type": "shell",
"command": "find /dev -name 'myspecialdevice*' -maxdepth 1"
}
]
}
问题是用户仍然被询问要运行哪个任务。我对launch.json 的inputs.args 部分最不安全。我真的不知道关键值应该是什么。也许implementation 有助于解决这个问题?
【问题讨论】:
-
让
command输入类型工作也难倒我。来自code.visualstudio.com/docs/editor/… 的pickString示例就像一个魅力,但没有command的示例,并且到目前为止所有逻辑尝试都失败了......这是否有效?在 Ubuntu 18.04 上使用 1.39.2 Visual Studio Code。