Class: RSwift::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/rswift/cli.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = [], local_options = {}, config = {}) ⇒ CLI

Returns a new instance of CLI.



8
9
10
11
12
# File 'lib/rswift/cli.rb', line 8

def initialize(args = [], local_options = {}, config = {})
  super
  @template_manager = RSwift::TemplateManager.new
  @project_configurator = RSwift::ProjectConfigurator.new
end

Instance Attribute Details

#project_configuratorObject

Returns the value of attribute project_configurator.



6
7
8
# File 'lib/rswift/cli.rb', line 6

def project_configurator
  @project_configurator
end

#template_managerObject

Returns the value of attribute template_manager.



5
6
7
# File 'lib/rswift/cli.rb', line 5

def template_manager
  @template_manager
end

Instance Method Details

#app(name) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/rswift/cli.rb', line 17

def app(name)
  template = options[:template]
  template ||= 'ios'
  template = template.to_sym
  abort 'Available templates: ios (default), osx, tvos, watchos' unless RSwift::Constants::TEMPLATE_PROPERTIES.keys.include? template
  abort 'Not implemented yet' if template == :watchos

  @template_manager.create_files_for_template(name, template)

  project_path = "#{name}/#{name}.xcodeproj"
  project = Xcodeproj::Project.new project_path
  @project_configurator.configure_project(project, template)
  project.save
  say_status :generate, project_path
end