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

"Could not find input with command" pop up while trying the commandvariable's exemple #131

Open
roussak opened this issue Feb 3, 2025 · 5 comments · May be fixed by #134
Open

"Could not find input with command" pop up while trying the commandvariable's exemple #131

roussak opened this issue Feb 3, 2025 · 5 comments · May be fixed by #134

Comments

@roussak
Copy link

roussak commented Feb 3, 2025

See the comment.

It looks like it relates to the #79.

@MarcelRobitaille
Copy link
Collaborator

It's unlikely that this is related to 79 because that was closed 2 years ago.

Please indicate the version of the extension that you are using and your exact tasks.json.

@MarcelRobitaille MarcelRobitaille added the question Further information is requested label Feb 3, 2025
@roussak
Copy link
Author

roussak commented Feb 4, 2025

Version is 1.15.0

The JSON is:

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "Get Option String",
      "type": "shell",
      "command": "echo \"The option string is '${input:getOptionString}' and the selection option is '${input:selectedOption}'\"",
      "problemMatcher": []
    }
  ],
  "inputs": [
    {
      "id": "getOptionString",
      "type": "command",
      "command": "extension.commandvariable.transform",
      "args": {
        "key": "optionString",
        "text": "${command:getOptionString}",
        "command": {
          "getOptionString": {
            "command": "shellCommand.execute",
            "variableSubstArgs": true,
            "args": {
              "command": "echo You selected ${pickStringRemember:pickAnOption}",
              "useSingleResult": true,
            },
            "pickStringRemember": {
              "pickAnOption": {
                "key": "selectedOption",
                "description": "Pick an option",
                "options": [
                  { "label": "Previous option:",
                    "value": "${remember:selectedOption}",
                    "description": "${remember:selectedOption}"
                  },
                  "Option A",
                  "Option B",
                  "Option C",
                  "Option D"
                ]
              }
            }
          }
        }
      }
    },
    {
      "id": "selectedOption",
      "type": "command",
      "command": "extension.commandvariable.remember",
      "args": { "key": "selectedOption" }
    }
  ]
}

@roussak
Copy link
Author

roussak commented Feb 4, 2025

It's unlikely that this is related to 79 because that was closed 2 years ago.

Image

But, exactly this ticket is mentioned in the comment on the screenshot. And exactly in the resolveTaskToInput() the exception being thrown. In general, the resolveTaskToInput() is built in a very strange manner:

  • It solves exactly one narrow task: to substitute the ${workspaceFolder} (only!) var if it was found in the input.
  • It re-reads the source of the input's instead of using of the given command and/or arguments. Furthermore, the criteria of that the command is found is the current command from an array is equal to the given one — whether two (or even more) equal commands cannot be defined?..

Though, of course, I can make a mistake because I came to these conclusions after a cursory acquaintance with the sources…

@MarcelRobitaille
Copy link
Collaborator

Hi @roussak. Thanks for your answer. I think the problem is some lack of support between commandvariable.transform and this extension. I'm not familiar with commandvariable.transform. What are you trying to do?

Could you please try adding a taskId to your shellCommand task?

roussak added a commit to roussak/vscode-shell-command that referenced this issue Feb 4, 2025
…#131

The very presence of an "Id" in the name suggests that this entity must
be something unique. But, previously the "taskId" was used among of the
command and its arguments while searching the input object in the
resolveTaskToInput() function. Among of other effects, this was leading
to exception throwing for the use-case like described in the ticket
(combined usage of the Shell Command and CommandVariable extensions
usage). This patch if doesn't fix this issue, then gives a workaround
for it. Specifying the "taskId" for the Shell Command calls lets the
variables substitution with CommandVariable extension (using the
`variableSubstArgs` argument).
@roussak
Copy link
Author

roussak commented Feb 4, 2025

Could you please try adding a taskId to your shellCommand task?

This gives nothing.

Please, review my PR (by the way, it allows the taskId using to solve the issue).

roussak added a commit to roussak/vscode-shell-command that referenced this issue Feb 4, 2025
…#131

The very presence of an "Id" in the name suggests that this entity must
be something unique. But, previously the "taskId" was used among of the
command and its arguments while searching the input object in the
resolveTaskToInput() function. Among of other effects, this was leading
to exception throwing for the use-case like described in the ticket
(combined usage of the Shell Command and CommandVariable extensions
usage). This patch if doesn't fix this issue, then gives a workaround
for it. Specifying the "taskId" for the Shell Command calls lets the
variables substitution with CommandVariable extension (using the
`variableSubstArgs` argument).
roussak added a commit to roussak/vscode-shell-command that referenced this issue Feb 4, 2025
…#131

The very presence of an "Id" in the name suggests that this entity must
be something unique. But, previously the "taskId" was used among of the
command and its arguments while searching the input object in the
resolveTaskToInput() function. Among of other effects, this was leading
to exception throwing for the use-case like described in the ticket
(combined usage of the Shell Command and CommandVariable extensions
usage). This patch if doesn't fix this issue, then gives a workaround
for it. Specifying the "taskId" for the Shell Command calls lets the
variables substitution with CommandVariable extension (using the
`variableSubstArgs` argument).
@MarcelRobitaille MarcelRobitaille removed the question Further information is requested label Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants