Class: Devkitkat::Main

Inherits:
Object
  • Object
show all
Defined in:
lib/devkitkat/main.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMain

Returns a new instance of Main.



5
6
7
8
# File 'lib/devkitkat/main.rb', line 5

def initialize
  @command = Command.new
  @config = Config.new(command.kit_root)
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



3
4
5
# File 'lib/devkitkat/main.rb', line 3

def command
  @command
end

#configObject (readonly)

Returns the value of attribute config.



3
4
5
# File 'lib/devkitkat/main.rb', line 3

def config
  @config
end

Instance Method Details

#executeObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/devkitkat/main.rb', line 10

def execute
  if command.tty? && target_services.count > 1
    raise ArgumentError, 'TTY mode accepts only one service'
  end

  results = []

  print_log_paths

  if target_services.count == 1
    # If the target is only one, it could be console access (TTY)
    # so we can't run in parallel.
    results << target_services.first.execute
  else
    results = Parallel.map(target_services, progress: 'Executing', in_processes: 8) do |service|
      service.execute.tap do |success|
        raise Parallel::Kill unless success
      end
    end
  end

  exit(1) unless results&.all? { |result| result == true }
end