4 ms·
I have a very specific technical (UX) reason for using `print()` to debug sometimes. In VS Code, if you want to run debugger with arguments (especially for CLI
by thrdbndndn 2y ago
I have a very specific technical (UX) reason for using `print()` to debug sometimes.
In VS Code, if you want to run debugger with arguments (especially for CLI programs), you have to put these arguments in launch.json and then run the debugger.
This is often tedious to do, because I usually have typed these arguments and tested in terminal before, and now I have to convert them into json format, which is annoying.
To make it worse, VS Code uses a separate window for debug console than your main terminal, so they don't share history/output.
So if I know what to look at already and don't really need a full debugger, I often just use print() temporally.
- skissane 2y agoI have the same issue. The tool I’m working on has a CLI with multiple subcommands. So I just added a REPL subcommand to my CLI. That way, I can start the CLI REPL in VSCode debug and then paste in the subcommand/arguments I want to debug.
- shlomo_z 2y agoYes, this is extremely frustrating sometimes.
- Nilithus 2y agoI'm pretty sure you could use something like https://code.visualstudio.com/docs/editor/variables-reference#_input-variables https://code.visualstudio.com/docs/editor/variables-referenc... to allow you to copy and paste your args into a user prompt when you initiate the debugger so you don't have to convert them to json first for each command you want.