Sha256: 69fd57f50d1728e9b31e30866796805e9c821d7074c264cf5826cb29afd08b6d

Contents?: true

Size: 581 Bytes

Versions: 6

Compression:

Stored size: 581 Bytes

Contents

require 'tins'

module Utils
  module Pager
    module_function

    def pager(command: nil, lines: nil, &block)
      if block
        if my_pager = pager(command:, lines:)
          IO.popen(my_pager, 'w') do |output|
            output.sync = true
            yield output
            output.close
          end
        else
          yield STDOUT
        end
      else
        return unless STDOUT.tty?
        if lines
          if lines >= Tins::Terminal.lines
            pager(command:)
          end
        else
          command
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
utils-0.59.2 lib/utils/pager.rb
utils-0.59.1 lib/utils/pager.rb
utils-0.59.0 lib/utils/pager.rb
utils-0.58.0 lib/utils/pager.rb
utils-0.57.1 lib/utils/pager.rb
utils-0.57.0 lib/utils/pager.rb