Class: Rake::Application

Inherits:
Object
  • Object
show all
Defined in:
lib/stratus/cli.rb

Overview

:stopdoc: Monkey patches so that rake displays the correct application name in the help messages.

Instance Method Summary collapse

Instance Method Details

#display_prerequisitesObject



155
156
157
158
159
160
# File 'lib/stratus/cli.rb', line 155

def display_prerequisites
  tasks.each do |t|
    puts "#{name} #{t.name}"
    t.prerequisites.each { |pre| puts "    #{pre}" }
  end
end

#display_tasks_and_commentsObject



162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'lib/stratus/cli.rb', line 162

def display_tasks_and_comments
  displayable_tasks = tasks.select { |t|
    t.comment && t.name =~ options.show_task_pattern
  }
  if options.full_description
    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
    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
  end
end

#standard_exception_handlingObject

Provide standard execption handling for the given block.



185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# File 'lib/stratus/cli.rb', line 185

def standard_exception_handling
  begin
    yield
  rescue SystemExit => ex
    # Exit silently with current status
    exit(ex.status)
  rescue SystemExit, OptionParser::InvalidOption => ex
    # Exit silently
    exit(1)
  rescue Exception => ex
    return if ex.message =~ /Rakefile/
    # Exit with error message
    $stderr.puts "#{name} aborted!"
    $stderr.puts "!> #{ex.message}"
    if options.trace
      $stderr.puts ex.backtrace.join("\n")
    else
      $stderr.puts ex.backtrace.find {|str| str =~ /#{@rakefile}/ } || ""
      $stderr.puts "(See full trace by running task with --trace)"
    end
    exit(1)
  end
end