Sha256: 5ff66452ba9c99def8357f63e4cd631664ca4930a6eb2366b2eba50b6e559fc1

Contents?: true

Size: 1.01 KB

Versions: 21

Compression:

Stored size: 1.01 KB

Contents

require 'highline'

# work around problem where HighLine detects an eof on $stdin and raises an
# error.
HighLine.track_eof = false

module Capistrano
  class CLI
    module UI
      def self.included(base) #:nodoc:
        base.extend(ClassMethods)
      end

      module ClassMethods
        # Return the object that provides UI-specific methods, such as prompts
        # and more.
        def ui
          @ui ||= HighLine.new
        end

        # Prompt for a password using echo suppression.
        def password_prompt(prompt="Password: ")
          ui.ask(prompt) { |q| q.echo = false }
        end

        # Debug mode prompt
        def debug_prompt(cmd)
          ui.say("Preparing to execute command: #{cmd}")
          prompt = "Execute ([Yes], No, Abort) "
          ui.ask("#{prompt}?  ") do |q|
            q.overwrite = false
            q.default = 'y'
            q.validate = /(y(es)?)|(no?)|(a(bort)?|\n)/i
            q.responses[:not_valid] = prompt
          end
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
capistrano-2.15.11 lib/capistrano/cli/ui.rb
capistrano-2.15.10 lib/capistrano/cli/ui.rb
capistrano-2.15.9 lib/capistrano/cli/ui.rb
capistrano-2.15.8 lib/capistrano/cli/ui.rb
capistrano-2.15.7 lib/capistrano/cli/ui.rb
capistrano-2.15.6 lib/capistrano/cli/ui.rb
capistrano-2.15.5 lib/capistrano/cli/ui.rb
minmb-capistrano-2.15.4 lib/capistrano/cli/ui.rb
capistrano-2.15.4 lib/capistrano/cli/ui.rb
capistrano-2.15.3 lib/capistrano/cli/ui.rb
capistrano-2.15.2 lib/capistrano/cli/ui.rb
capistrano-2.15.0 lib/capistrano/cli/ui.rb
capistrano-2.15.1 lib/capistrano/cli/ui.rb
capistrano-2.14.2 lib/capistrano/cli/ui.rb
capistrano-2.14.1 lib/capistrano/cli/ui.rb
capistrano-2.13.5 lib/capistrano/cli/ui.rb
capistrano-2.12.0 lib/capistrano/cli/ui.rb
capistrano-2.11.2 lib/capistrano/cli/ui.rb
capistrano-2.9.0 lib/capistrano/cli/ui.rb
capistrano-2.8.0 lib/capistrano/cli/ui.rb