Class: HammerCLIForeman::ReportTemplate::ReportDataCommand

Inherits:
DownloadCommand
  • Object
show all
Defined in:
lib/hammer_cli_foreman/report_template.rb

Instance Method Summary collapse

Methods inherited from DownloadCommand

command_name, #request_options, #saved_response_message

Instance Method Details

#default_filenameObject



171
172
173
# File 'lib/hammer_cli_foreman/report_template.rb', line 171

def default_filename
  "Report-#{Time.new.strftime("%Y-%m-%d")}.txt"
end

#executeObject



177
178
179
180
181
182
183
184
185
186
# File 'lib/hammer_cli_foreman/report_template.rb', line 177

def execute
  response = send_request
  if response.code == 204
    print_message(_('The report is not ready yet.'))
    HammerCLI::EX_TEMPFAIL
  else
    handle_success(response)
    HammerCLI::EX_OK
  end
end

#handle_success(response) ⇒ Object



188
189
190
191
192
193
194
195
# File 'lib/hammer_cli_foreman/report_template.rb', line 188

def handle_success(response)
  if option_path
    filepath = store_response(response)
    print_message(_('The response has been saved to %{path}.'), {:path => filepath})
  else
    puts response.body
  end
end