Class: PolyglotIos::Command::Setup

Inherits:
Projects
  • Object
show all
Includes:
Helper::General, Helper::Terminal
Defined in:
lib/ios_polyglot_cli/commands/setup.rb

Constant Summary

Constants included from Helper::General

Helper::General::ESCAPE_KEYWORDS

Instance Attribute Summary

Attributes inherited from Projects

#options

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helper::General

#clean_case_name, #clean_enum_name, #clean_variable_name, #config, #escape_keyword_if_needed, #escape_with_underscore_if_needed, #indent, #programming_language, #project_configs, #skip_writing_language_struct, #token, #token_env_variable, #url, #use_old_naming

Methods included from Helper::Terminal

#generate_token_message, #prompt, #success

Methods inherited from Projects

#filtered_projects, #option_query, #option_token, #projects

Constructor Details

#initialize(options = Commander::Command::Options.new) ⇒ Setup

Returns a new instance of Setup.



14
15
16
# File 'lib/ios_polyglot_cli/commands/setup.rb', line 14

def initialize(options = Commander::Command::Options.new)
  @options = options
end

Class Method Details

.init(options = Commander::Command::Options.new) ⇒ Object



10
11
12
# File 'lib/ios_polyglot_cli/commands/setup.rb', line 10

def self.init(options = Commander::Command::Options.new)
  new(options).call
end

Instance Method Details

#callObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/ios_polyglot_cli/commands/setup.rb', line 18

def call
  customUrl = option_site_url || custom_url_prompt
  project_id = project_id_prompt
  language = language_prompt
  translations_path = translations_path_prompt
  sources_path = sources_path_prompt
  token_env_variable = custom_token_env_var_prompt
  project = {
    id: project_id,
    path: translations_path,
    sourceFilesPath: sources_path
  }
  config = {
    language: language,
    projects: [project],
    url: customUrl,
    token_env_variable: token_env_variable
  }
  PolyglotIos::IO::Config.write(config)
  success
end