Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: plain mix task generator #138

Open
axelson opened this issue Nov 2, 2024 · 7 comments
Open

Proposal: plain mix task generator #138

axelson opened this issue Nov 2, 2024 · 7 comments
Labels
enhancement New feature or request

Comments

@axelson
Copy link
Contributor

axelson commented Nov 2, 2024

Is your feature request related to a problem? Please describe.
I occasionally need to generate a new mix task for a end project that I'm working on. When I do so I usually have to lookup the syntax (and path) for generating a mix task.

Describe the solution you'd like
A new igniter task like mix igniter.gen.mix_task that generates a mix task that is expected to run without igniter (e.g. so it can run even in MIX_ENV=prod mode or in a project that won't continue to use Igniter). The generated task will follow best practices/nudges such as providing an explicit example and documenting options. Also mix igniter.gen.mix_task would provide options that would optionally add a @requirements ["app.config"] line so that config/runtime.exs is loaded.

This would also help me not forget to add things like @shortdoc which (if I recall correctly) is required for the mix task to be visible via mix help.

Describe alternatives you've considered
Generating the mix task by hand or modifying the mix task generated by mix igniter.gen.task

Additional context
Maybe instead of a new igniter task it should be an argument to mix igniter.gen.task so that users don't get confused about which type of task to generate (or perhaps the existing task could be renamed to something like mix igniter.gen.igniter_task)

@axelson axelson added the enhancement New feature or request label Nov 2, 2024
@axelson axelson changed the title Propsal: plain mix task generator Proposal: plain mix task generator Nov 2, 2024
@zachdaniel
Copy link
Contributor

🤔 yeah, this makes sense to me. I think what we'd do is (soft) deprecate igniter.gen.task in favor of igniter.gen.mix_task which could have an --igniter flag to make it an igniter task.

@zachdaniel
Copy link
Contributor

Since it will all be the same task it would be a pretty easy change to make, basically just make the current one call Mix.Tasks.....run("igniter.gen.mix_task", argv ++ ["--igniter"]), and then add another branch to not add the igniter stuff. PRs welcome!

@zachallaun
Copy link
Collaborator

I think what we'd do is (soft) deprecate igniter.gen.task in favor of igniter.gen.mix_task which could have an --igniter flag to make it an igniter task.

What about the inverse? Keep igniter.gen.task and add --no-igniter to generate a non-Igniter Mix task. A bit less churn that way.

@zachdaniel
Copy link
Contributor

🤔 potentially...but to me if this is the "generate a mix task" generator, then it feels weird for igniter to be the default.

@zachallaun
Copy link
Collaborator

zachallaun commented Nov 5, 2024

Maybe, but I'd guess that most libraries don't use mix tasks at all, and if they are using Igniter to generate a task, it's probably because they want an Igniter task 🙂 (read: they're only writing a task in order to use Igniter!)

Eventually, this could also be an interactive prompt that asks what kind of task you want generated (bare mix, igniter task, igniter upgrade task).

In the meantime, IMO, add support for generating bare mix tasks without deprecating/changing anything (so add mix igniter.gen.task --no-igniter) and then we can sit with that for a bit and decide whether there's a better default going forward. I don't think we need to couple those decisions.

@zachdaniel
Copy link
Contributor

Right, I see your point 👍 I'm down w/ just --no-igniter as a starting point.

@axelson
Copy link
Contributor Author

axelson commented Nov 7, 2024

I think rather than --no-igniter, it would be more clear if this used something like a --type flag to indicate the "type" of the mix task that will be generated. I'm thinking this because when I first tried igniter.gen.mix_task I thought that mix igniter.gen.mix_task --optional would generate a plain mix task that would "work" (as in do the work it is meant to do) whether igniter is available or not. But instead what it does is generate a mix task that won't crash if igniter is not available.

So if we added --no-igniter (and presumably --igniter) alongside --optional I think it would be confusing to end-users. But I think that mix igniter.gen.mix_task --type igniter and mix igniter.gen.mix_task --type plain (or mix?) would make it clear what will be generated for people that are not as familiar with igniter and what/how optionality matters. Also we'd probably ignore --optional if --type plain is passed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants