tooltitude / support

Tooltitude Support
https://www.tooltitude.com
Other
21 stars 0 forks source link

Improve the behavior of run and debug code lens #9

Open faceair opened 1 year ago

faceair commented 1 year ago

Feature request:

The current behavior of the run and debug code lens is to run directly. However, in my project, it is generally necessary to add additional command-line parameters when running, and running directly will result in an error.

This feature is implemented in Goland as follows:

  1. Click run or debug.
  2. Add a launch config with a default name.
  3. Run this launch config. If this launch config is renamed later, clicking run again will add a launch config with a default name and run it.

Therefore, I think Tooltitude can implement this feature with a similar approach. Automatically adding a launch config can help me save some trouble, and I can add command-line parameters myself.

tooltitude-support commented 1 year ago

Go plugin for vscode has run configuration functionality. Do you use it? We could try to find relevant run configuration for the file, and run it instead of running in the plain way. What do you think?

faceair commented 1 year ago

Yes, I am currently using the launch config (launch.json) for vscode.

Now I need to manually add the path of the main package, which is a bit inconvenient. It would be great if a new configuration item could be automatically added for me when I click "run" code len.

tooltitude-support commented 1 year ago

@faceair Ok. We will think how it could be done without making the feature harder to use. Thanks again for the feedback!

tooltitude-support commented 1 year ago

@faceair I have an idea. What if you provide a comment before the main method like: // tt:run-with: [arg1, arg2, arg3]. Will it work for you? Do you need some local path there?

faceair commented 1 year ago

Hi, according to my previous description, there is no need to add specific command-line parameters in tooltitude.

Here's an example:

  1. Click on the "run code len" file in cmd/cli/main.go.
  2. Tooltitude looks for a configuration with the name "launch cmd/cli/main.go" in .vscode/launch.json. If found, it launches it directly.
  3. If not found, Tooltitude adds the configuration with the above name, helps me fill in the full address of the program, and launches it.

In most cases where command line arguments are not required, the program can be launched directly.

If my CLI program cannot be launched, I would modify the "args" parameter in launch.json manually, but usually, there's no need to modify the configuration name. When I manually add the "args" parameter and click "run code len" again, Tooltitude will find the "launch cmd/cli/main.go" configuration and launch it correctly.