Class: PolyglotCli::Command::Setup

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helper::General

#config, #languages, #project, #project_id, #remote_translations, #select_languages, #server_changed?, #token, #update_config

Methods included from Helper::Terminal

#prompt, #success

Constructor Details

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

Returns a new instance of Setup.



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

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

Instance Attribute Details

#subdomainObject (readonly)

override subdomain for the setup, use the cached value (from prompt) instead of reading it from the config file (which does not exist yet during the setup)



34
35
36
# File 'lib/polyglot_cli/commands/setup.rb', line 34

def subdomain
  @subdomain
end

Class Method Details

.init(options) ⇒ Object



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

def self.init(options)
  new(options).call
end

Instance Method Details

#callObject



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/polyglot_cli/commands/setup.rb', line 18

def call
  @config = {
    subdomain: subdomain_prompt,
    project_id: project_id_prompt,
    locale_path: locale_path_prompt
  }
  PolyglotCli::IO::Config.write(@config.merge(locale_mapping: locale_mapping))
  success
rescue TTY::Prompt::ConfigurationError
  prompt.error('Could not find any projects. Please try a new search.')
end