class MaintenanceTasks::CLI
Defines the command line interface commands exposed by Maintenance Tasks in the executable file.
Public Class Methods
exit_on_failure?()
click to toggle source
Return a failed exit status in case of an error.
# File lib/maintenance_tasks/cli.rb, line 11 def exit_on_failure? true end
Public Instance Methods
perform(name)
click to toggle source
Command to run a Task.
It instantiates a Runner and sends a run message with the given Task name. If a CSV file is supplied using the –csv option, an attachable with the File IO object is sent along with the Task name to run. If arguments are supplied using the –arguments option, these are also passed to run.
@param name [String] the name of the Task to be run.
# File lib/maintenance_tasks/cli.rb, line 43 def perform(name) arguments = options[:arguments] || {} task = Runner.run(name: name, csv_file: csv_file, arguments: arguments) say_status(:success, "#{task.name} was enqueued.", :green) rescue => error say_status(:error, error.message, :red) end
Private Instance Methods
csv_file()
click to toggle source
# File lib/maintenance_tasks/cli.rb, line 53 def csv_file csv_option = options[:csv] if csv_option { io: File.open(csv_option), filename: File.basename(csv_option) } end end