Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nesting of input variables #210656

Open
thebit94 opened this issue Apr 18, 2024 · 1 comment
Open

Nesting of input variables #210656

thebit94 opened this issue Apr 18, 2024 · 1 comment
Assignees
Labels
feature-request Request for new features or functionality tasks Task system issues

Comments

@thebit94
Copy link

thebit94 commented Apr 18, 2024

Does this issue occur when all extensions are disabled?: Yes/No

  • VS Code Version: 1.88.1
  • OS Version: Linux x64 6.5.0-1018-oem snap

Steps to Reproduce:

The documentation (https://code.visualstudio.com/docs/editor/variables-reference#_why-arent-variables-in-tasksjson-being-resolved)
states that "Input variables in the inputs section will not be resolved as nesting of input variables is not supported.

First of all that's not true (it's supported with limitations)
Second it is quite powerful to fully support it!
Lets take this example:

"inputs": [
	{
            "id": "get_pid",
            "type": "command",
            "command": "shellCommand.execute",
            "args": {
                "command": "docker exec ${input:get_container_id} pidof xxx" //replace xxx with a process name
            }
        },
        {
            "id": "get_container_id",
            "type": "command",
            "command": "shellCommand.execute",
            "args": {
                "command": "docker ps --format \"{{.ID}}\""
            },
        },
]
...

As we can see "get_pid" needs "get_container_id" and both of them are reference later in the configuration.

In the code above it won't work as the first ${input:get_container_id} will be evaluated to empty string.
One workaround to make it working is to "dummy" references the ${input:get_container_id} in the configuration before referencing ${input:get_pid}
(Then even if you delete that dummy reference it will keep working until you restart VSCode)

Another nicer workaround would be to use variables and invoke the input command first:

	       "variables": { 
                "containerId": "${input:get_container_id}",
                "pid": "${input:get_pid}", //Important: the precedence is important otherwise they won't evaluate (this command depending on the previous one)
                },

So could you please fully support this

"

@meganrogge meganrogge added feature-request Request for new features or functionality tasks Task system issues labels Apr 18, 2024
@VSCodeTriageBot VSCodeTriageBot added this to the Backlog Candidates milestone Apr 18, 2024
@VSCodeTriageBot
Copy link
Collaborator

This feature request is now a candidate for our backlog. The community has 60 days to upvote the issue. If it receives 20 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our documentation.

Happy Coding!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality tasks Task system issues
Projects
None yet
Development

No branches or pull requests

3 participants