1

I am getting started using VSCode withe the rust-analyzer plugin. I really like the ">Run" "shortcuts" that the plugin adds to all the functions and tests.

How can I pass in command line arguments to these shortcuts ?

I tried to edit the launch.json file and added in the command line arguments there. But these get passed in only when I call --Main Menu--Run--Run without debugging.

Is there a way to configure the "Run" "shortcut" to accept arguments?

I am attaching a snapshot of the "shortcut" button ( around line 22) in case I am not describing it accurately. Screenshot of VSCode window with "Run" Shortcut around line 22

The launch.json below allowed me to pass command line arguments to "Run" that gets called from the Main Menu--using Run--Run without debugging . However that is slower and runs in a separate console. Is there an easy way to pass arguments to the shortcut?

    {
        // 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": [
            {
                "type": "lldb",
                "request": "launch",
                "name": "Debug executable 'gcd_euclid_cli'",
                "cargo": {
                    "args": [
                        "build",
                        "--bin=gcd_euclid_cli",
                        "--package=gcd_euclid_cli"
                    ],
                    "filter": {
                        "name": "gcd_euclid_cli",
                        "kind": "bin"
                    }
                },
                "args": ["1024", "578"],
                "cwd": "${workspaceFolder}"
            },
            {
                "type": "lldb",
                "request": "launch",
                "name": "Debug unit tests in executable 'gcd_euclid_cli'",
                "cargo": {
                    "args": [
                        "test",
                        "--no-run",
                        "--bin=gcd_euclid_cli",
                        "--package=gcd_euclid_cli"
                    ],
                    "filter": {
                        "name": "gcd_euclid_cli",
                        "kind": "bin"
                    }
                },
                "args": ["1024", "578"],
                "cwd": "${workspaceFolder}"
            }
        ]
    }
harijay
  • 11,303
  • 12
  • 38
  • 52

0 Answers0