Skip to content

Commit 4af1151

Browse files
sevenc-nanashihsbt
authored andcommitted
Add: -l option
1 parent 7685262 commit 4af1151

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
@@ -134,6 +134,8 @@ def top_level
134134
display_tasks_and_comments
135135
elsif options.show_prereqs
136136
display_prerequisites
137+
elsif options.show_location
138+
display_location
137139
else
138140
top_level_tasks.each { |task_name| invoke_task(task_name) }
139141
end
@@ -364,6 +366,12 @@ def display_tasks_and_comments # :nodoc:
364366
end
365367
end
366368

369+
# Display the location of the Rakefile.
370+
def display_location
371+
rakefile, location = find_rakefile_location
372+
puts File.join(location, rakefile)
373+
end
374+
367375
def terminal_width # :nodoc:
368376
if @terminal_columns.nonzero?
369377
result = @terminal_columns
@@ -528,6 +536,10 @@ def standard_rake_options # :nodoc:
528536
"Include LIBDIR in the search path for required modules.",
529537
lambda { |value| $:.push(value) }
530538
],
539+
["--location", "-l",
540+
"Display the location of Rakefile, then exit.",
541+
lambda { |value| options.show_location = true }
542+
],
531543
["--multitask", "-m",
532544
"Treat all tasks as multitasks.",
533545
lambda { |value| options.always_multitask = true }
@@ -839,6 +851,7 @@ def set_default_options # :nodoc:
839851
options.nosearch = false
840852
options.rakelib = %w[rakelib]
841853
options.show_all_tasks = false
854+
options.show_location = false
842855
options.show_prereqs = false
843856
options.show_task_pattern = nil
844857
options.show_tasks = nil

0 commit comments

Comments
 (0)