Method: WebTranslateIt::CommandLine#initialize

Defined in:
lib/web_translate_it/command_line.rb

#initialize(command, command_options, _global_options, parameters, project_path) ⇒ CommandLine

rubocop:todo Metrics/CyclomaticComplexity, Metrics/MethodLength



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/web_translate_it/command_line.rb', line 9

def initialize(command, command_options, _global_options, parameters, project_path) # rubocop:todo Metrics/CyclomaticComplexity, Metrics/MethodLength
  self.command_options = command_options
  self.parameters = parameters
  unless command == 'init'
    message = case command
    when 'pull'
      'Pulling files'
    when 'push'
      'Pushing files'
    when 'add'
      'Creating master files'
    when 'rm'
      'Deleting files'
    when 'mv'
      'Moving files'
    when 'addlocale'
      'Adding locale'
    when 'rmlocale'
      'Deleting locale'
    else
      'Gathering information'
    end
    throb do
      print "  #{message}"
      self.configuration = WebTranslateIt::Configuration.new(project_path, configuration_file_path)
      print " #{message} on #{configuration.project_name}"
    end
  end
  success = send(command)
  exit 1 unless success
end