Class: PolyglotFlutter::Command::Setup

Inherits:
Projects
  • Object
show all
Includes:
Helper::General, Helper::Terminal
Defined in:
lib/flutter_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_enum_name, #clean_variable_name, #config, #escape_keyword_if_needed, #escape_with_underscore_if_needed, #extract_translations, #generate_locales, #generate_localization_keys, #indent, #mandatory_language, #programming_language, #project_configs, #token, #use_old_naming

Methods included from Helper::Terminal

#prompt, #success

Methods inherited from Projects

#filtered_projects, #option_query, #projects

Constructor Details

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

Returns a new instance of Setup.



14
15
16
# File 'lib/flutter_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/flutter_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
# File 'lib/flutter_polyglot_cli/commands/setup.rb', line 18

def call
  project_id = project_id_prompt
  language = 'dart'
  translations_path = translations_path_prompt
  sources_path = sources_path_prompt
  mandatory_language = mandatory_language_prompt
  project = {
    id: project_id,
    path: translations_path,
    sourceFilesPath: sources_path
  }
  config = {
    language: language,
    projects: [project],
    mandatory_language: mandatory_language
  }
  PolyglotFlutter::IO::Config.write(config)
  success
end