Sha256: ec9a87bd8933fb5866ec5ae379ed15cbbf153f67ec942acdc5377e0db43d3972

Contents?: true

Size: 1.1 KB

Versions: 5

Compression:

Stored size: 1.1 KB

Contents

require 'tty-command'

module Autowow
  module Executor
    class Pretty < TTY::Command::Printers::Pretty
      def print_command_out_data(cmd, *args); end
      def print_command_err_data(cmd, *args); end
      def print_command_exit(cmd, status, runtime, *args)
        super
        write('')
      end
    end

    class PrettyWithOutput < TTY::Command::Printers::Pretty
      def print_command_exit(cmd, status, runtime, *args)
        super
        write('')
      end
    end

    class RunWrapper
      def initialize(tty_command)
        @tty_command = tty_command
      end

      def run(array)
        @tty_command.run(*array)
      end

      def run!(array)
        @tty_command.run!(*array)
      end
    end

    def pretty
      @pretty ||= RunWrapper.new(TTY::Command.new(pty: true, printer: Pretty))
    end

    def pretty_with_output
      @pretty_with_output ||= RunWrapper.new(TTY::Command.new(pty: true, printer: PrettyWithOutput))
    end

    def quiet
      @quiet ||= RunWrapper.new(TTY::Command.new(pty: true, printer: :null))
    end

    include ReflectionUtils::CreateModuleFunctions
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
autowow-0.8.0 lib/autowow/executor.rb
autowow-0.7.0 lib/autowow/executor.rb
autowow-0.6.3 lib/autowow/executor.rb
autowow-0.6.0 lib/autowow/executor.rb
autowow-0.5.0 lib/autowow/executor.rb