module Puppet::Util::Terminal
Public Class Methods
width()
click to toggle source
Attempts to determine the width of the terminal. This is currently only supported on POSIX
systems, and relies on the claims of `stty` (or `tput`).
Inspired by code from Thor; thanks wycats! @return [Number] The column width of the terminal. Defaults to 80 columns.
# File lib/puppet/util/terminal.rb 7 def self.width 8 if Puppet.features.posix? 9 result = %x{stty size 2>/dev/null}.split[1] || 10 %x{tput cols 2>/dev/null}.split[0] 11 end 12 return (result || '80').to_i 13 rescue 14 return 80 15 end