Class: Localeapp::CLI::Rename

Inherits:
Command
  • Object
show all
Includes:
ApiCall
Defined in:
lib/localeapp/cli/rename.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(current_name, new_name, *rest) ⇒ Object



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

def execute(current_name, new_name,  *rest)
  @output.puts "Localeapp mv"
  @output.puts ""
  @output.puts "Renaming key: #{current_name} to #{new_name}"
  api_call :rename,
    :url_options => { :current_name => current_name },
    :payload => { :new_name => new_name },
    :success => :report_success,
    :failure => :report_failure,
    :max_connection_attempts => 1
end

#report_failure(response) ⇒ Object



22
23
24
25
# File 'lib/localeapp/cli/rename.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/rename.rb', line 18

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