Sha256: 1dbf5d57610bdd63c2e43763d00ee819a988902945f6c3e9aff1b748da2e0d9f

Contents?: true

Size: 791 Bytes

Versions: 4

Compression:

Stored size: 791 Bytes

Contents

module Puppet::Module::Tool
  module Utils

    # = Interrogation
    #
    # This module contains methods to emit text to the console, such as headers.
    module Interrogation

      def header(text)
        $stderr.puts('=' * text.size, text, "-" * text.size)
      end

      def say(*args)
        $stderr.puts(*args)
      end

      def subheader(line)
        say line, ('-' * line.size)
      end

      def confirms?(question)
        $stderr.print "#{question} [y/N]: "
        $stdin.gets =~ /y/i
      end

      def prompt(question, quiet = false)
        $stderr.print "#{question}: "
        system 'stty -echo' if quiet
        $stdin.gets.strip
      ensure
        if quiet
          system 'stty echo'
          say "\n---------"
        end
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
puppet-module-0.3.4 lib/puppet/module/tool/utils/interrogation.rb
puppet-module-0.3.3 lib/puppet/module/tool/utils/interrogation.rb
puppet-module-0.3.2 lib/puppet/module/tool/utils/interrogation.rb
puppet-module-0.3.0 lib/puppet/module/tool/utils/interrogation.rb