Class: Localeapp::CLI::Copy

Inherits:
Command
  • Object
show all
Includes:
ApiCall
Defined in:
lib/localeapp/cli/copy.rb

Instance Method Summary collapse

Methods included from ApiCall

#api_call

Methods inherited from Command

#initialize, #initialize_config, #load_config_file, #set_command_line_arguments

Constructor Details

This class inherits a constructor from Localeapp::CLI::Command

Instance Method Details

#execute(source_name, dest_name, *rest) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/localeapp/cli/copy.rb', line 6

def execute(source_name, dest_name, *rest)
  @output.puts "Localeapp cp"
  @output.puts ""
  @output.puts "Copying key: #{source_name} to #{dest_name}"
  api_call :copy,
    :url_options => { :source_name => source_name },
    :payload => { :dest_name => dest_name },
    :success => :report_success,
    :failure => :report_failure,
    :max_connection_attempts => 1
end

#report_failure(response) ⇒ Object



22
23
24
25
# File 'lib/localeapp/cli/copy.rb', line 22

def report_failure(response)
  @output.puts "Failed!"
  fail APIResponseError, "API returned #{response.code} status code"
end

#report_success(response) ⇒ Object



18
19
20
# File 'lib/localeapp/cli/copy.rb', line 18

def report_success(response)
  @output.puts "Success!"
end