Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add: -location option #445

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions lib/rake/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 }
Expand Down Expand Up @@ -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
Expand Down