stepup.core.interact¶
Application Programming Interface (API) for interactive use of the director process.
Most of these functions are used for writing tests. They can also be employed to create keyboard shortcuts within your IDE.
For example, one may bind the following command to an IDE’s keyboard shortcut:
STEPUP_DIRECTOR_SOCKET=$(python -c "import stepup.core.director; print(stepup.core.director.get_socket())") python -c 'from stepup.core.interact import run; run()'
This command must be executed in the top-level directory
where a stepup command is running in interactive mode.
You can better understand how the above example works by breaking it down into two parts:
- The command 
python -c "import stepup.core.director; print(stepup.core.director.get_socket())"prints the path to the socket where the director listens for instructions. This is a randomized temporary path that is created whenstepupis started. (For technical reasons, this path cannot be deterministic and must be read from.stepup/log/director.) By wrapping this command inSTEPUP_DIRECTOR_SOCKET=$(...), the path will be assigned to an environment variableSTEPUP_DIRECTOR_SOCKET, which will be available for the second Python call. - 
The part
python -c 'from stepup.core.interact import run; run()'has the same effect as pressingrin the terminal where StepUp is running. The variableSTEPUP_DIRECTOR_SOCKETtells which instance of StepUp to interact with.(When StepUp runs
plan.pyscripts, they also use this environment variable to interact with the director process. Because these are subprocesses of the director, theSTEPUP_DIRECTOR_SOCKETis set by the director.) 
Configuration of a Task in VSCode¶
You can define a Custom Task in VSCode to start the run phase of a StepUp instance running in a terminal.
For this example, we will assume the following:
- You have an 
.envrcfile that defines the environment variableSTEPUP_ROOTand you have configured and installed direnv. - You have an interactive StepUp instance running in a terminal (with 
stepup -w). - You want to use the 
ctrl+'keybinding to start the run phase while you are editing a file in the StepUp project. 
Add the following to your user tasks.json file:
{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "StepUp run",
      "type": "shell",
      "command": "eval \"$(direnv export bash)\"; STEPUP_DIRECTOR_SOCKET=$(python -c 'import stepup.core.director; print(stepup.core.director.get_socket())') python -c 'from stepup.core.interact import run; run()'",
      "options": {
        "cwd": "${fileDirname}"
      },
      "presentation": {
        "echo": true,
        "reveal": "silent",
        "focus": false,
        "panel": "shared",
        "showReuseMessage": false,
        "clear": true
      }
    }
  ]
}
This will create a task that executes the command in the directory of the file you are editing.
With eval "$(direnv export bash)", the environment variables from your .envrc file are loaded.
The rest of the command field is the same as the command we used in the first example.
The following keybindings.json file will bind ctrl+' to run the task:
VSCode will automatically save the file when you run the task with this keybinding.
Instead of this shortcut, you can also use stepup -W,
which will automatically rerun the build as soon as you delete, save or add a relevant file.