require 'tty/command' require 'tty/prompt' require 'ptools' require 'toolrack' require_relative 'command_result' module Docker module Cli class Command include TR::CondUtils attr_accessor :command_buffer def initialize(cmd, required_interaction = false) @command_buffer = cmd @runner = TTY::Command.new @required_interaction = required_interaction @required_interaction = false if not_bool?(@required_interaction) end def interactive_session? @required_interaction end def run(&block) if interactive_session? pmt = TTY::Prompt.new terminal = pmt.select "Command is an interactive command. New terminal session is required. Please select one of the session below to proceed:" do |m| detect_terminal.each do |t| m.choice t, t end m.choice "Quit", :quit end if terminal != :quit case terminal when "terminator" `#{terminal} -x "#{@command_buffer.join(" ")}"` when "gnome-terminal" `#{terminal} -- bash -c "#{@command_buffer.join(" ")}; exec bash"` when "iTerm2" `osascript <