Class: Capistrano::Shell

Inherits:
Object
  • Object
show all
Defined in:
lib/capistrano/shell.rb

Defined Under Namespace

Classes: ReadlineFallback

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(actor) ⇒ Shell

Instantiate a new shell



19
20
21
# File 'lib/capistrano/shell.rb', line 19

def initialize(actor)
  @actor = actor
end

Instance Attribute Details

#actorObject (readonly)

The actor instance employed by this shell



11
12
13
# File 'lib/capistrano/shell.rb', line 11

def actor
  @actor
end

Class Method Details

.run!(actor) ⇒ Object

Instantiate a new shell and begin executing it immediately.



14
15
16
# File 'lib/capistrano/shell.rb', line 14

def self.run!(actor)
  new(actor).run!
end

Instance Method Details

#run!Object

Start the shell running. This method will block until the shell terminates.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/capistrano/shell.rb', line 25

def run!
  setup

  puts <<-INTRO
====================================================================
Welcome to the interactive Capistrano shell! This is an experimental
feature, and is liable to change in future releases.
--------------------------------------------------------------------
INTRO

  loop do
    command = @reader.readline("cap> ", true)

    case command ? command.strip : command
      when "" then next
      when "help"  then help
      when nil, "quit", "exit" then
        puts if command.nil?
        puts "exiting"
        break
      when /^set -(\w)\s*(\S+)/
        set_option($1, $2)
      when /^(?:(with|on)\s*(\S+))?\s*(\S.*)?/i
        process_command($1, $2, $3)
      else
        raise "eh?"
    end
  end

  @bgthread.kill
end