cancel
Showing results for 
Search instead for 
Did you mean: 

Update Magento command-line tool (CLI) to be included globally in Mac / Linux

0 Kudos

Update Magento command-line tool (CLI) to be included globally in Mac / Linux

I really love the Magento command-line tool, however I would like to see the command line tool integrated in Linux / Mac.

 

By doing that we could extend the native functionalities and be able to use the magento command with those new commands from any project.

 

 

Problems

  1. Right now, if you want to add new commands to manage your Magento 2 installations, you have to add a new module with the code for the new commands to the project. So, if several community members contribute with different commands, the result is that you have several modules containing all those commands.

  2. For the same reason that the item above, if you create new commands to add new cool features, the code for those features should be added to every single Magento 2 project (as a result, more code in the codebase of those projects).

  3. If the command-line is included in the Magento 2 codebase (in the projects), it's very hard to extend and maintain for the reasons mentioned above. Magerun2 is the best example of how powerful and useful is a global command-line tool: https://github.com/netz98/n98-magerun2.

Suggestions

 

Since I've been contributing with the community by creating a command-line tool for Mac (https://github.com/guarinogabriel/Mac-CLI), I have a couple of suggestions to improve the Magento 2 command-line tool:

 

  1. Release it as the Magento command-line tool in Github: It could be a separate project in Github, so the community can focus on contributing specific features/improvements to the CLI.

  2. Make it global: The Magento installer could install the tool in the /usr/local/bin/ folder to make the command-line tool global in the system. 

  3. Auto-complete features: The perfect example of this is the SAWS command line tool (https://github.com/donnemartin/saws):
    687474703a2f2f692e696d6775722e636f6d2f767a43357a6d412e676966.gif

  4. Magento 2 could use the global magento command-line tool: One of the goals of the Magento 2 command-line tool is to replace the shell scripts from Magento 1 and use commands in Magento 2 instead. Those commands could be appended to the global command line tool. So, if you run the magento command from the project folder, the commands from that project will be appended to the global commands.

 

I'd love contributing with this idea by creating a pull request and start working on the global command-line tool if the Magento team and the community like it.

2 Comments
Magento Master

Have you seen https://github.com/yvoronoy/magento2-bash-completion ?

 

I think there are two types of shell commands:

 

1.) that are applicable to any Magento instance

2.) that are tied against a specific instance, for example some extensions might come with a shell command, but this would only be available if the extension is installed. Only having a global command line would make this a lot harder.

 

For 1.) a separated project makes sense when Magento version differences can be abstracted out. Overall I think Magerun2 is already the defacto global command line tool and I would suggest simply contributing there.

Moderator

I wasn't aware of that Github project (Magento 2 bash completion), however it doesn't work for the people who use zsh instead of bash.

 

Regarding the point #2, that would be the technical challenge to resolve by making the command-line global.

Basically, it would work exactly the same, with the commands of the new modules being appended to the global command line.