Skip to content

Instantly share code, notes, and snippets.

@dux
Created April 9, 2016 12:27
Show Gist options
  • Save dux/ceab0f222074a75596d54e5aae966a8d to your computer and use it in GitHub Desktop.
Save dux/ceab0f222074a75596d54e5aae966a8d to your computer and use it in GitHub Desktop.
adds menu choser to default rake task
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
Webapp::Application.load_tasks
### Custom
Rake::Task["default"].clear
require 'colorize'
task :default do
tasks = `rake -T`.split("\n")
tasks.each_with_index do |el, i|
num = i + 1
puts "#{num.to_s.rjust(3)}. #{el}"
end
print "Execute task: "
val = STDIN.gets.chomp
task = tasks[val.to_i-1].to_s.split(/\s+#/).first
if task
puts "Executing: #{task.yellow}"
system task
else
puts 'Taks not found'.red
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment