Skip to content

Commit 5ea5123

Browse files
Add: -l option
1 parent 30fbf4e commit 5ea5123

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

lib/rake/application.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ def top_level
112112
display_tasks_and_comments
113113
elsif options.show_prereqs
114114
display_prerequisites
115+
elsif options.show_location
116+
display_location
115117
else
116118
top_level_tasks.each { |task_name| invoke_task(task_name) }
117119
end
@@ -334,6 +336,12 @@ def display_tasks_and_comments # :nodoc:
334336
end
335337
end
336338

339+
# Display the location of the Rakefile.
340+
def display_location
341+
rakefile, location = find_rakefile_location
342+
puts File.join(location, rakefile)
343+
end
344+
337345
def terminal_width # :nodoc:
338346
if @terminal_columns.nonzero?
339347
result = @terminal_columns
@@ -498,6 +506,10 @@ def standard_rake_options # :nodoc:
498506
"Include LIBDIR in the search path for required modules.",
499507
lambda { |value| $:.push(value) }
500508
],
509+
["--location", "-l",
510+
"Display the location of Rakefile, then exit.",
511+
lambda { |value| options.show_location = true }
512+
],
501513
["--multitask", "-m",
502514
"Treat all tasks as multitasks.",
503515
lambda { |value| options.always_multitask = true }
@@ -816,6 +828,7 @@ def set_default_options # :nodoc:
816828
options.nosearch = false
817829
options.rakelib = %w[rakelib]
818830
options.show_all_tasks = false
831+
options.show_location = false
819832
options.show_prereqs = false
820833
options.show_task_pattern = nil
821834
options.show_tasks = nil

0 commit comments

Comments
 (0)