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, #find_app_language, #generate_locales, #generate_localization_keys, #generate_static_locales, #generate_strings, #indent, #project_configs, #token

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
37
38
39
40
41
42
43
# File 'lib/flutter_polyglot_cli/commands/setup.rb', line 18

def call
  project_id = project_id_prompt
  flutter_instance = flutter_instance_prompt
  l10n_path = './l10n.yaml'
  output_localization_file = 'app_localizations'
  set_default_langauge = false
  translations_path = translations_path_prompt
  
  sources_path = sources_path_prompt
  mandatory_language = mandatory_language_prompt
  project = {
    id: project_id,
    flutterInstance: flutter_instance,
    mandatoryLanguage: mandatory_language,
    path: translations_path,
    l10nFilePath: l10n_path,
    sourceFilesPath: sources_path,
    outputLocalizationFile: output_localization_file,
    setDefaultLangauge: set_default_langauge,
  }
  config = {
    projects: [project],
  }
  PolyglotFlutter::IO::Config.write(config)
  success
end