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 8 def self.width 9 if Puppet.features.posix? 10 result = %x{stty size 2>/dev/null}.split[1] || 11 %x{tput cols 2>/dev/null}.split[0] 12 end 13 return (result || '80').to_i 14 rescue 15 return 80 16 end