remix-project icon indicating copy to clipboard operation
remix-project copied to clipboard

Is it possible to add a custom terminal command using?

Open kwkr opened this issue 5 months ago • 9 comments

Let's say I want to be able to write a custom deploy command in the terminal and then some action should be executed. Is this possible to achieve somehow, maybe using a plugin?

kwkr avatar Feb 29 '24 12:02 kwkr

It's easy to add this. But I need to inquire about the community and get a clear answer. Hold on, I will give you feedback.

fwx5618177 avatar Mar 01 '24 02:03 fwx5618177

and then some action should be executed

what kind of action do you have in mind? @kwkr

yann300 avatar Mar 01 '24 08:03 yann300

Actually anything. The simplest example would be, that I have some state within my plugin and I would like to register a command that would allow me to display info about the plugin to the console. Like plugin-name info. And this could trigger some custom logic to be executed.

kwkr avatar Mar 01 '24 08:03 kwkr

hmm ok so you could:

  • write a ts script, that wll act as your command ( your plugin can just put this script in the file system). then users would be able to execute this script.
  • from this plugin you can write things like: remix.call('a-plugin-name', 'a-function-in-that-plugin', arg1, arg2, arg3) this will call your plugin and change its state.

yann300 avatar Mar 01 '24 15:03 yann300

I already experimented with some workarounds but having the possibility to be able to register custom commands and let the users type them in the terminal would be quite a different experience.

kwkr avatar Mar 02 '24 08:03 kwkr

what would be ideal syntax for running these custom commands from the terminal?

yann300 avatar Mar 02 '24 09:03 yann300

I could imagine having an API available from within a plugin where I call registerCommand("command_name", handler) and if a plugin does this, I could just type command_name in terminal to do something. It coul also somehow take into account some plugin prefix to avoid command clashes from different plugings like my_plugin command_name.

kwkr avatar Mar 02 '24 09:03 kwkr

the command would then run a function from a plugin right? would commands accept parameters? how?

yann300 avatar Mar 02 '24 10:03 yann300

yes. The commands could also potentially accept arguments but I don't know how could this be achieved. There is already a way to communicate between plugins and remix so I assume some event could be triggered with the arguments passed to the command and then the plugin could react to it and extract the params from the event.

kwkr avatar Mar 02 '24 10:03 kwkr