visual-studio-code - 将输入字符串映射到 launch.json 文件中的数值
问题描述
我有以下 launch.json 文件:
{
"version": "0.2.0",
"configurations": [
{
"name": "Service1",
"type": "python",
"request": "attach",
"connect": {
"host": "127.0.0.1",
"port": "${input:envType}"
},
...
},
...
],
"inputs": [
{
"type": "pickString",
"id": "envType",
"description": "Which env do you want to debug?",
"options": [
"development",
"staging",
"live",
],
"default": "development"
},
]
我想要实现的是:将特定环境映射到端口。例如,我希望如果用户选择“开发”环境,将在端口字段中打印的值是 5000。
这可能吗?
解决方案
您可以使用扩展命令变量v1.18.0
{
"version": "0.2.0",
"configurations": [
{
"name": "Service1",
"type": "python",
"request": "attach",
"connect": {
"host": "127.0.0.1",
"port": "${input:envType}"
}
}
],
"inputs": [
{
"id": "envType",
"type": "command",
"command": "extension.commandvariable.pickStringRemember",
"args": {
"description": "Which env do you want to debug?",
"options": [
["development", "5000"],
["staging", "5100"],
["live", "5200"]
],
"default": "5000"
}
}
]
}
推荐阅读
- encoding - 如何让Java显示画框字符?我得到问号
- excel - 验证 Excel 文件
- python - 如何通过按下按钮(python)将我的变量提高 1?
- javascript - 如何访问嵌套的javascript数组中的特定字段
- r - 如何将 for 循环的每次迭代的结果恢复到自己的矩阵中?
- kotlin - build.gradle.kts 遵循 githubs 指南:配置 Gradle 以与 GitHub 包一起使用。但它未能找到“来自”功能
- python - 在一个数组中组合数组
- python - 如何让python文件复制自己然后执行另一个副本一次?
- pre-commit-hook - 在子文件夹中使用 setup.cfg 预先提交 flake8
- java - 无法从 MySql 获取特定数据