我知道如何在launch.json 中傳遞固定引數,例如在Visual Studio Code 中,如何在launch.json 中傳遞引數。我真正需要的是一個提示,我可以在其中為發生變化的論點賦值。
此外,我的論點是一個(資料)目錄,其中有一個非常難看的長絕對路徑。我真的很希望能夠將作業目錄設定為包含我的每個單獨資料目錄的路徑,所以我只需要提供一個相對目錄路徑,即只是目錄名稱。
我正在使用 VS Code 1.55.2(也不是我的選擇)在 Windows(不是我的選擇)上使用 Python。
uj5u.com熱心網友回復:
您可以使用輸入變數
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File with arguments",
"type": "python",
"request": "launch",
"program": "${file}",
"args": [
"--dir",
"/some/fixed/dir/${input:enterDir}"
]
}
],
"inputs": [
{
"id": "enterDir",
"type": "promptString",
"description": "Subdirectory to process",
"default": "data-0034"
}
]
}
您可以將 放在${input:enterDir}任務中的任何字串中,"configurations"例如"cwd"屬性。
如果您想從串列中選擇一個目錄,因為它是動態的,您可以使用Command Variable具有命令pickFile的擴展名
命令變數 v1.36.0 支持fixed檔案夾規范。
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File with arguments",
"type": "python",
"request": "launch",
"program": "${file}",
"args": [
"--dir",
"${input:pickDir}"
]
}
],
"inputs": [
{
"id": "pickDir",
"type": "command",
"command": "extension.commandvariable.file.pickFile",
"args": {
"include": "**/*",
"display": "fileName",
"description": "Subdirectory to process",
"showDirs": true,
"fromFolder": { "fixed": "/some/fixed/dir" }
}
}
]
}
在類 Unix 系統上,您可以將檔案夾包含在includeglob 模式中。在 Windows 上,您必須使用fromFolder將目錄路徑轉換為可用的 glob 模式。如果您有多個檔案夾,則可以使用該predefined屬性。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/484009.html
上一篇:函式中的C#變數隨機變為不可用
