Class: HammerCLIForeman::DownloadCommand

Inherits:
SingleResourceCommand show all
Defined in:
lib/hammer_cli_foreman/commands.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

alias_name_for_resource, build_options, connection_name, create_option_builder, #customized_options, #dependency_resolver, dependency_resolver, #exception_handler_class, #get_identifier, #get_resource_id, #get_resource_ids, #request_params, resolver, #resolver, resource_alias_name_mapping, resource_config, resource_name_mapping, #searchables, searchables, #send_request, #transform_format

Class Method Details

.command_name(name = nil) ⇒ Object



732
733
734
# File 'lib/hammer_cli_foreman/commands.rb', line 732

def self.command_name(name = nil)
  super(name) || "download"
end

Instance Method Details

#default_filenameObject



758
759
760
# File 'lib/hammer_cli_foreman/commands.rb', line 758

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

#executeObject



743
744
745
746
747
748
749
750
751
752
# File 'lib/hammer_cli_foreman/commands.rb', line 743

def execute
  response = send_request
  if option_path
    filepath = store_response(response)
    print_message(saved_response_message(filepath))
  else
    puts response.body
  end
  return HammerCLI::EX_OK
end

#request_optionsObject



736
737
738
# File 'lib/hammer_cli_foreman/commands.rb', line 736

def request_options
  { :response => :raw }
end

#saved_response_message(filepath) ⇒ Object



754
755
756
# File 'lib/hammer_cli_foreman/commands.rb', line 754

def saved_response_message(filepath)
  _("The response has been saved to %{path}.") % { path: filepath }
end