vscode-shell-command icon indicating copy to clipboard operation
vscode-shell-command copied to clipboard

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

Open roussak opened this issue 1 year ago • 5 comments

See the comment.

It looks like it relates to the #79.

roussak avatar Feb 03 '25 06:02 roussak

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 avatar Feb 03 '25 20:02 MarcelRobitaille

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 avatar Feb 04 '25 03:02 roussak

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…

roussak avatar Feb 04 '25 05:02 roussak

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?

MarcelRobitaille avatar Feb 04 '25 09:02 MarcelRobitaille

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 avatar Feb 04 '25 09:02 roussak