10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/kuber_kit/shell/local_shell.rb', line 10
def exec!(command, log_command: true)
command_number = command_counter.get_number.to_s.rjust(2, "0")
if log_command
ui.print_debug("LocalShell", "Execute: [#{command_number}]: #{command.to_s.cyan}")
end
result = nil
IO.popen(command, err: [:child, :out]) do |io|
result = io.read.chomp.strip
end
if result && result != "" && log_command
ui.print_debug("LocalShell", "Finished [#{command_number}] with result: \n ----\n#{result.grey}\n ----")
end
if $?.exitstatus != 0
raise ShellError, "Shell command failed: #{command}\r\n#{result}"
end
result
end
|