diff --git a/lib/rake/application.rb b/lib/rake/application.rb index d4e2680f6..653ecd0c4 100644 --- a/lib/rake/application.rb +++ b/lib/rake/application.rb @@ -112,6 +112,8 @@ def top_level display_tasks_and_comments elsif options.show_prereqs display_prerequisites + elsif options.show_location + display_location else top_level_tasks.each { |task_name| invoke_task(task_name) } end @@ -334,6 +336,12 @@ def display_tasks_and_comments # :nodoc: end end + # Display the location of the Rakefile. + def display_location + rakefile, location = find_rakefile_location + puts File.join(location, rakefile) + end + def terminal_width # :nodoc: if @terminal_columns.nonzero? result = @terminal_columns @@ -498,6 +506,10 @@ def standard_rake_options # :nodoc: "Include LIBDIR in the search path for required modules.", lambda { |value| $:.push(value) } ], + ["--location", "-l", + "Display the location of Rakefile, then exit.", + lambda { |value| options.show_location = true } + ], ["--multitask", "-m", "Treat all tasks as multitasks.", lambda { |value| options.always_multitask = true } @@ -816,6 +828,7 @@ def set_default_options # :nodoc: options.nosearch = false options.rakelib = %w[rakelib] options.show_all_tasks = false + options.show_location = false options.show_prereqs = false options.show_task_pattern = nil options.show_tasks = nil