remix-project
remix-project copied to clipboard
Is it possible to add a custom terminal command using?
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?
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.
and then some action should be executed
what kind of action do you have in mind? @kwkr
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.
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.
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.
what would be ideal syntax for running these custom commands from the terminal?
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
.
the command would then run a function from a plugin right? would commands accept parameters? how?
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.