TLDR:
A builtin mix task to run mix tasks directly from hex or a git repository (an SCM).
`mix x phx_new phx.new`
Problem:
Currently if you would like to distribute a mix task or CLI tool, you either need to have the user first install an archive (like `mix archive.install hex phx_new`) or the user needs to package and distribute it themselves.
The Node.js ecosystem has a solution to this called `npx`, that enables a developer to run a CLI tool without globally installing a package or creating a project first. This is useful for many scaffolding CLIs that generate new projects: e.g., `npx create-react-app my-app`.
In Elixir, we have the powerful `Mix.install/2` function that can enable installing packages in iex or scripts without installing them globally (not currently possible at all unless I'm mistaken) or creating a new project.
This still requires the user to write a script or boot up iex.
Solution:
A builtin mix task to run mix tasks directly from hex or a git repository (an SCM).
`mix x phx_new phx.new`
Advantages:
- Easier way to distribute CLI tooling
- Remove a step from projects like phoenix for installing the scaffolding CLI
- Building this into Elixir (vs having a 3rd party CLI people can install) ensures that users have it and library authors can take advantage of it reliably
Disadvantages:
- Another feature to maintain
Considerations:
- What to name the mix task? The above is just not the real proposed name, just the closed thing to the `npx` convention
- Should libraries be able to declare a "default" task, such that `mix x phx_new` works without explicitly declaring the task?
Notes:
I have a script in my dotfiles that as a proof of concept
```elixir
#!/usr/bin/env elixir
[package, task | args] = System.argv()
Mix.install([String.to_atom(package)])
Mix.Task.run(task, args)
```
Let me know what you think!
- Mitch