This simple patch adds the --directory option that allows to change the
execution directory for rake.
thanks.
--
vic
Index: lib/rake.rb
===================================================================
RCS file: /var/cvs/rake/rake/lib/rake.rb,v
retrieving revision 1.126
diff -u -r1.126 rake.rb
--- lib/rake.rb 1 Mar 2006 12:53:01 -0000 1.126
+++ lib/rake.rb 7 Mar 2006 22:31:00 -0000
@@ -1477,6 +1477,8 @@
"Display the program version."],
['--classic-namespace', '-C', GetoptLong::NO_ARGUMENT,
"Put Task and FileTask in the top level namespace"],
+ ['--directory', '-d', GetoptLong::REQUIRED_ARGUMENT,
+ "Change to DIRECTORY before doing anything."]
]
# Create a Rake::Application object.
@@ -1604,6 +1606,10 @@
when '--classic-namespace'
require 'rake/classic_namespace'
options.classic_namespace = true
+ when '--directory'
+ dir = File.expand_path(value, original_dir)
+ fail "Not a directory: #{dir}" unless File.directory? dir
+ options.run_dir = dir
else
fail "Unknown option: #{opt}"
end
@@ -1709,15 +1715,17 @@
def run
handle_options
begin
- tasks = collect_tasks
- load_rakefile
- if options.show_tasks
- display_tasks_and_comments
- elsif options.show_prereqs
- display_prerequisites
- else
- tasks.each { |task_name| Rake::Task[task_name].invoke }
- end
+ Dir.chdir(options.run_dir || original_dir) do
+ tasks = collect_tasks
+ load_rakefile
+ if options.show_tasks
+ display_tasks_and_comments
+ elsif options.show_prereqs
+ display_prerequisites
+ else
+ tasks.each { |task_name| Rake::Task[task_name].invoke }
+ end
+ end
rescue Exception => ex
puts "rake aborted!"
puts ex.message
_______________________________________________
Rake-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rake-devel