lib/tty/pager.rb in tty-pager-0.11.0 vs lib/tty/pager.rb in tty-pager-0.12.0
- old
+ new
@@ -1,5 +1,7 @@
+# frozen_string_literal: true
+
require 'tty-screen'
require_relative 'pager/basic'
require_relative 'pager/null'
require_relative 'pager/system'
@@ -16,14 +18,14 @@
# command to perform pagination with SystemPager. Finally,
# if no system command is found, a BasicPager is used which
# is a pure Ruby implementation known to work on any platform.
#
# @api private
- def self.select_pager(enabled)
+ def self.select_pager(enabled, commands)
if !enabled
NullPager
- elsif SystemPager.exec_available?
+ elsif SystemPager.exec_available?(*commands)
SystemPager
else
BasicPager
end
end
@@ -39,16 +41,17 @@
# the object to send output to
# @option options [Boolean] :enabled
# disable/enable text paging
#
# @api public
- def initialize(options = {})
+ def initialize(**options)
@input = options.fetch(:input) { $stdin }
@output = options.fetch(:output) { $stdout }
@enabled = options.fetch(:enabled) { true }
+ commands = Array(options[:command])
if self.class == TTY::Pager
- @pager = self.class.select_pager(@enabled).new(options)
+ @pager = self.class.select_pager(@enabled, commands).new(options)
end
end
# Check if pager is enabled
#