KScript docs
EN

Debugging

launch.json

F5 with no launch.json debugs the script that is open. To give the script arguments, or always debug the same script, add a launch.json: open the Run and Debug view, click create a launch.json file and choose KScript. You may add as many configurations as you like:

JSON
{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "kscript",
      "request": "launch",
      "name": "Debug script",
      "program": "${file}"
    },
    {
      "type": "kscript",
      "request": "launch",
      "name": "Import this week's orders",
      "program": "${workspaceFolder}/main.kscript",
      "args": ["--week", "48"],
      "environment": "staging",
      "stopOnEntry": true
    }
  ]
}

A configuration may have:

Setting What it does
program The script to debug. ${file} is the one open in the editor.
args The script's $args, as after kscript run script.kscript.
cwd The folder the script runs in. The script's own folder when it is left out.
env Environment variables to set for the script, such as { "API_URL": "http://localhost:8080" }.
environment The environment for $config, as kscript --env staging picks it.
stopOnEntry true pauses before the script's first statement, without a breakpoint.

The script runs with its project's packages and config, from the nearest kscript.json, as kscript run runs it.