class Multish
Constants
- VERSION
Public Class Methods
run!(args)
click to toggle source
# File lib/multish.rb, line 297 def self.run!(args) self.new.run!(args) end
Public Instance Methods
errored?()
click to toggle source
# File lib/multish.rb, line 301 def errored? @commands.any?(&:errored?) end
run!(args)
click to toggle source
# File lib/multish.rb, line 305 def run!(args) @commands = args.each_with_index.map { |arg, index| MultishItem.new(arg, index, args.count) } Curses.init_screen Curses.start_color Curses.curs_set(0) Curses.use_default_colors Curses.cbreak @commands.each(&:create_window!) @commands.each(&:open_process!) fdlist = @commands.flat_map(&:streams) begin while true fdlist.reject!(&:closed?) break if fdlist.empty? ready = IO.select(fdlist)[0] ready.each do |fd| @commands.each { |command| command.try_update(fd) } end @commands.each(&:update_title!) break if @commands.all?(&:finished?) end rescue StandardError => e Curses.close_screen warn 'INTERNAL ERROR'.red warn e.message warn e.backtrace ensure Curses.curs_set(1) Curses.close_screen warn $log.join("\n").blue if errored? warn 'At least one of the commands exited with error.' @commands.select(&:errored?).each(&:print_output!) exit 1 else exit 0 end end end