#!/usr/bin/env ruby require 'optparse' require 'annotate' task = :annotate_models OptionParser.new do |opts| opts.banner = "Usage: annotate [options]" opts.on('-d', '--delete') { task = :remove_annotation } opts.on('-p', '--position [before|after]', ['before', 'after']) { |p| ENV['position'] = p } opts.on('-r', '--routes') { task = :annotate_routes } opts.on('-v', '--version') { puts "Annotate v#{Annotate::VERSION}"; exit } opts.on('-m', '--show-migration') { ENV['include_version'] = "yes" } end.parse! begin Rake::Task[task].invoke #TODO: rescue only rake error rescue NameError => e puts "Can`t find Rake. Are we in a Rails folder?" end