Permalink
Browse files

Show tasks using :tasks

  • Loading branch information...
1 parent d8090fd commit 6f8b9a0ffce8ea889cb52d11869113ae5a9a6854 @jimweirich committed May 18, 2009
Showing with 11 additions and 2 deletions.
  1. +5 −2 lib/rake/application.rb
  2. +6 −0 test/lib/application_test.rb
View
7 lib/rake/application.rb
@@ -178,21 +178,24 @@ def display_tasks_and_comments
displayable_tasks = tasks.select { |t|
t.comment && t.name =~ options.show_task_pattern
}
- if options.show_tasks == :describe
+ case options.show_tasks
+ when :describe
displayable_tasks.each do |t|
puts "#{name} #{t.name_with_args}"
t.full_comment.split("\n").each do |line|
puts " #{line}"
end
puts
end
- else
+ when :tasks
width = displayable_tasks.collect { |t| t.name_with_args.length }.max || 10
max_column = truncate_output? ? terminal_width - name.size - width - 7 : nil
displayable_tasks.each do |t|
printf "#{name} %-#{width}s # %s\n",
t.name_with_args, max_column ? truncate(t.comment, max_column) : t.comment
end
+ else
+ fail "Unknown show task mode: '#{options.show_tasks}'"
end
end
View
6 test/lib/application_test.rb
@@ -33,6 +33,7 @@ def test_constant_warning
end
def test_display_tasks
+ @app.options.show_tasks = :tasks
@app.options.show_task_pattern = //
@app.last_description = "COMMENT"
@app.define_task(Rake::Task, "t")
@@ -43,6 +44,7 @@ def test_display_tasks
def test_display_tasks_with_long_comments
in_environment('RAKE_COLUMNS' => '80') do
+ @app.options.show_tasks = :tasks
@app.options.show_task_pattern = //
@app.last_description = "1234567890" * 8
@app.define_task(Rake::Task, "t")
@@ -54,6 +56,7 @@ def test_display_tasks_with_long_comments
def test_display_tasks_with_task_name_wider_than_tty_display
in_environment('RAKE_COLUMNS' => '80') do
+ @app.options.show_tasks = :tasks
@app.options.show_task_pattern = //
description = "something short"
task_name = "task name" * 80
@@ -66,6 +69,7 @@ def test_display_tasks_with_task_name_wider_than_tty_display
end
def test_display_tasks_with_very_long_task_name_to_a_non_tty_shows_name_and_comment
+ @app.options.show_tasks = :tasks
@app.options.show_task_pattern = //
@app.tty_output = false
description = "something short"
@@ -78,6 +82,7 @@ def test_display_tasks_with_very_long_task_name_to_a_non_tty_shows_name_and_comm
end
def test_display_tasks_with_long_comments_to_a_non_tty_shows_entire_comment
+ @app.options.show_tasks = :tasks
@app.options.show_task_pattern = //
@app.tty_output = false
@app.last_description = "1234567890" * 8
@@ -89,6 +94,7 @@ def test_display_tasks_with_long_comments_to_a_non_tty_shows_entire_comment
def test_display_tasks_with_long_comments_to_a_non_tty_with_columns_set_truncates_comments
in_environment("RAKE_COLUMNS" => '80') do
+ @app.options.show_tasks = :tasks
@app.options.show_task_pattern = //
@app.tty_output = false
@app.last_description = "1234567890" * 8

0 comments on commit 6f8b9a0

Please sign in to comment.