"insert here" the result of an API call

Greetings

 

I'm using PHPStorm to build sites which includes assets from asset servers.

I was wondering if there would be clever/simple way to implement my workflow:

- when editing a file in PHPStorm, start the tools somehow

- the tool itself could be some kind of bash/whatever I wrote myself

- insert the output of the tool as a string where I was when starting it

 

The problem I think is that it contains an asynchronous API call (sending a file to a server and getting a public URL back).

 

What do you think?

 

Thanks in advance

 

Regards

0
2 comments

Hi,

- when editing a file in PHPStorm, start the tools somehow

At the quick glance, this part can be covered by File Watchers:
https://www.jetbrains.com/help/phpstorm/2023.3/settings-tools-file-watchers.html

insert the output of the tool as a string where I was when starting it

Not sure how to deal with this part though.

 

Probably, IDE Scripting Console may help:
https://www.jetbrains.com/help/phpstorm/ide-scripting-console.html

But it is bit of a tricky way as it is not well documented.

0

At the quick glance, this part can be covered by File Watchers:

Nah .. This request is more like External Tools / Live Templates functionality to me.

@Greg 

https://youtrack.jetbrains.com/issue/IDEA-76371 – there are a few recipes in the comments of how others are doing similar stuff. E.g. call the custom command, get the output and put it into a clipboard. Then, when it finish running, paste the result back manually via standard Ctrl+V.  A bit too much IMO,  but you can execute such an action via custom shortcut / menu item.

You can also use Live Templates (but have to use the Groovy script for that). A bit different invocation logic but can put the output right in the editor. I have not used any of them (have no need for such stuff) so make sure to check all the comments there.

You can even find 2 plugins mentioned in the last few comments that can help with that.

P.S. The above is how I understood your request.

0

Please sign in to leave a comment.