diff --git a/lib/rake/application.rb b/lib/rake/application.rb index 87ae47b32..6c535ff59 100644 --- a/lib/rake/application.rb +++ b/lib/rake/application.rb @@ -134,6 +134,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 @@ -364,6 +366,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 @@ -528,6 +536,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 } @@ -839,6 +851,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