bin/fez in fezzik-0.2.0 vs bin/fez in fezzik-0.3.0

- old
+ new

@@ -7,7 +7,46 @@ require "colorize" # Include everything in config/recipes Dir[File.join(Dir.pwd, 'config/recipes/**/*.rb')].sort.each { |lib| require lib } -Rake.application["fezzik:run"].invoke +def usage + <<-EOF +fez <destination> <tasks> # Run deployment tasks on destination servers +fez get <recipes> # Download recipes to use in your project +fez -T # Display all tasks + EOF +end +def display_tasks_and_exit + Rake.application.options.show_task_pattern = // + output = capture_output { Rake.application.display_tasks_and_comments } + output.gsub!(/^rake fezzik:/, "fez <destination> ") + puts output + exit 0 +end + +RECIPE_URL = "https://github.com/dmacdougall/fezzik/raw/master/recipes" +def download_recipes_and_exit + system("mkdir -p config/recipes") + ARGV[1..-1].each do |recipe| + recipe += ".rb" unless recipe[-3..-1] == ".rb" + system("curl -f #{RECIPE_URL}/#{recipe} -o config/recipes/#{recipe} > /dev/null 2>&1") + if $? == 0 + puts " [new]".green + " config/recipes/#{recipe}" + else + puts " [fail]".red + " config/recipes/#{recipe}" + end + end + exit 0 +end + +if ARGV.size == 0 + puts usage + exit 1 +elsif ARGV[0] == "-T" + display_tasks_and_exit +elsif ARGV[0] == "get" + download_recipes_and_exit +end + +Rake.application["fezzik:run"].invoke