Module: Atlasq::Shell
- Defined in:
- lib/atlasq/shell.rb
Constant Summary collapse
- SKIP_PAGER =
%i[usage version].freeze
- DEFAULT_SHELL_HEIGHT =
24
Class Method Summary collapse
Class Method Details
.start!(args = ARGV) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/atlasq/shell.rb', line 8 def self.start!(args = ARGV) warn "DEBUG: args: #{args}" if DEBUG = Command.parse(args) warn "DEBUG: options: #{}" if DEBUG content = .command.run(.args) if content.empty? Atlasq.failed! elsif use_pager?(, content) require "tty-pager" TTY::Pager.page(content) else puts content end exit(1) if Atlasq.failed? end |
.use_pager?(options, content) ⇒ Boolean
31 32 33 34 35 |
# File 'lib/atlasq/shell.rb', line 31 def self.use_pager?(, content) $stdout.tty? && .command.to_pager? && content.count("\n") >= DEFAULT_SHELL_HEIGHT end |