提交 48529963 编写于 作者: J Justin Collins

Add --rake option to install rake task

上级 b2eb4a25
......@@ -27,6 +27,9 @@ elsif options[:show_help]
elsif options[:show_version]
puts "brakeman #{Brakeman::Version}"
exit
elsif options[:install_rake_task]
Brakeman.install_rake_task
exit
end
#Set application path according to the commandline arguments
......
......@@ -145,6 +145,32 @@ module Brakeman
$stderr.puts Checks.checks.map { |c| c.to_s }.sort.join "\n"
end
def self.install_rake_task
if not File.exists? "Rakefile"
abort "No Rakefile detected"
elsif File.exists? "lib/tasks/brakeman.rake"
abort "Task already exists"
end
require 'fileutils'
if not File.exists? "lib/tasks"
warn "Creating lib/tasks"
FileUtils.mkdir_p "lib/tasks"
end
path = File.expand_path(File.dirname(__FILE__))
FileUtils.cp "#{path}/brakeman/brakeman.rake", "lib/tasks/brakeman.rake"
if File.exists? "lib/tasks/brakeman.rake"
warn "Task created in lib/tasks/brakeman.rake"
warn "Usage: rake brakeman:run[output_file]"
else
warn "Could not create task"
end
end
def self.dump_config options
if options[:create_config].is_a? String
file = options[:create_config]
......
......@@ -175,6 +175,10 @@ module Brakeman::Options
options[:list_checks] = true
end
opts.on "--rake", "Create rake task to run Brakeman" do
options[:install_rake_task] = true
end
opts.on "-v", "--version", "Show Brakeman version" do
options[:show_version] = true
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册