Sha256: 13b17941605fb178779a5573a43530fdbca437a491282d791567da94c4b31257

Contents?: true

Size: 573 Bytes

Versions: 12

Compression:

Stored size: 573 Bytes

Contents

# frozen_string_literal: true

module Puppet::Util::Terminal
  # 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.
  def self.width
    if Puppet.features.posix?
      result = %x{stty size 2>/dev/null}.split[1] ||
               %x{tput cols 2>/dev/null}.split[0]
    end
    return (result || '80').to_i
  rescue
    return 80
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
puppet-8.5.1 lib/puppet/util/terminal.rb
puppet-8.5.1-x86-mingw32 lib/puppet/util/terminal.rb
puppet-8.5.1-x64-mingw32 lib/puppet/util/terminal.rb
puppet-8.5.1-universal-darwin lib/puppet/util/terminal.rb
puppet-8.5.0 lib/puppet/util/terminal.rb
puppet-8.5.0-x86-mingw32 lib/puppet/util/terminal.rb
puppet-8.5.0-x64-mingw32 lib/puppet/util/terminal.rb
puppet-8.5.0-universal-darwin lib/puppet/util/terminal.rb
puppet-8.4.0 lib/puppet/util/terminal.rb
puppet-8.4.0-x86-mingw32 lib/puppet/util/terminal.rb
puppet-8.4.0-x64-mingw32 lib/puppet/util/terminal.rb
puppet-8.4.0-universal-darwin lib/puppet/util/terminal.rb