gpt4 book ai didi

visual-studio-code - vscode : command for user input in debug launch config

转载 作者:行者123 更新时间:2023-12-03 20:30:41 28 4
gpt4 key购买 nike

我想做一些类似于 this documentation 中概述的事情用于选择进程,但我只想输入任何字符串:

{
"name": "Attach to Process",
"type": "node",
"request": "attach",
"processId": "${command:PickProcess}",
"port": 9229
}

是否有可用于获取任何用户输入的命令?理想情况下,我可以做这样的事情:
{
"name": "Launch Chrome Debug",
"type": "chrome",
"request": "launch",
"url": "http://localhost:8080/?id=${command:UserInput}",
"webRoot": "${workspaceRoot}",
}

这样我就可以在启动调试器时指定“id”参数。

最佳答案

v1.30 增加了这个功能:input variables during tasks and debug .

For user input variables, we introduced a new variable category input, which results in this syntax: ${input:variableName}. This simple syntax is not sufficient to present meaningful UI to the end user, so we've introduced a new inputs section in launch.json and tasks.json, where additional configuration attributes are specified.



input example

Here is the list of supported attributes:

id - The corresponding variable name for which these attributes are used.

type - The type of user input widget. In this release, promptString (for a string InputBox) and pickString (for a string Quick Pick) are supported.

description - Descriptive text shown to the user.

default - The default value to use if the user just presses Enter.

A first example shows how to use a user input variable in a task configuration (tasks.json):


{
"tasks": [
{
"label": "Echo input",
"type": "shell",
"command": "echo ${input:echoPrompt}"
}
],
"inputs": [
{
"id": "echoPrompt",
"description": "Please enter a value",
"default": "default echo text",
"type": "promptString"
}
]
}

Another example shows a user input variable for selecting between two options in a debug configuration (launch.json):


{
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}/${input:pickProgram}"
}
],
"inputs": [
{
"id": "pickProgram",
"description": "Select client or server",
"type": "pickString",
"options": ["client.js", "server.js"],
"default": "client.js"
}
]
}

We plan to combine user input variables with the existing command-based variables so that user input variables can be contributed by extensions.

关于visual-studio-code - vscode : command for user input in debug launch config,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48273346/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com