-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Feature request: keyword to specify a default stage #2072
Comments
Hi @Fjan thanks for the report. Have you considered defining your task like:
I'm shooting a bit here from the hip, but logically this says "backup_task depends on backup_server", if memory serves the "env" task ( If this works, I'd prefer it over the introduction of a new configuration option, could you try it out and let me know please? |
Interesting suggestion, and I agree that might be better than introducing a new configuration option. It doesn't currently work however. It looks like |
Thanks for checking that so fast. I think we could refine/patch How would you feel about that? |
Yes, it looks like there already is a |
It turns out that this can be done by adding a single line to the module Capistrano
module TaskEnhancements
def ensure_stage
Rake::Task.define_task(:ensure_stage) do
next if @top_level_tasks.any?{|task| !(Rake::Task[task.split('[').first].prerequisites & stages).empty?}
unless stage_set?
puts t(:stage_not_set)
exit 1
end
end
end
end
end |
I would like the option to specify a default stage for a task. I have a number of tasks that only make sense to run on a particular stage, so I find myself typing:
cap backup_server backup_task
orcap logging_server logging_task
To save myself from typing out the stage name for these I optimised my workflow a little by adding:
But this is a bit brittle as it depends on argument order (and depending on plugins it complains about load:default getting loaded twice). It would be really nice if the DSL allowed me to specify
default_stage <task> => <stage>
or something like that.Looking at the code it seems it should be fairly straightforward to add this. If we take a shortcut by using the existing DSL and do
set :default_stage, {task: stage}
then it would just require a few additional lines in the taskensure_stage
intask_enhancements.rb
. But it would be nicer to add a properdefault_stage
keyword so that it can be called multiple times so you can call it in the same place where the task is defined.What do people think?
The text was updated successfully, but these errors were encountered: