visual-studio-code

How can I view or print the return value of a VS Code command?


I am using Azure Developer CLI VS Code extension:

https://marketplace.visualstudio.com/items?itemName=ms-azuretools.azure-dev

Azure Developer CLI generated the following .vscode/launch.json file:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug Web",
            "request": "launch",
            "type": "msedge",
            "webRoot": "${workspaceFolder}/src/web/src",
            "url": "http://localhost:3000",
            "sourceMapPathOverrides": {
                "webpack:///src/*": "${webRoot}/*"
            }, 
        },

        {
            "name": "Debug API",
            "request": "launch",
            "runtimeArgs": [
                "run",
                "start"
            ],
            "runtimeExecutable": "npm",
            "skipFiles": [
                "<node_internals>/**"
            ],
            "type": "node",
            "cwd": "${workspaceFolder}/src/api",
            "envFile": "${input:dotEnvFilePath}",
            "env": {
                "NODE_ENV": "development"
            },
            "preLaunchTask": "Restore API",
            "outputCapture": "std"
        },
    ],

    "inputs": [
        {
            "id": "dotEnvFilePath",
            "type": "command",
            "command": "azure-dev.commands.getDotEnvFilePath"
        }
    ]
}

I note the mysterious azure-dev.commands.getDotEnvFilePath command.

How can I have VS Code show (or print) what is returned by the azure-dev.commands.getDotEnvFilePath command?


Solution

  • This is almost the same as Can I see the values of the Variables References in Visual Studio Code?. You should be able to do this by writing a shell task that prints the substitution of the corresponding command variable. Ex.

    {
      "version": "2.0.0",
      "tasks": [
        {
          "label": "echo",
          "type": "shell",
          "command": "echo '${command:commandID}'"
        }
      ]
    }