Class: Capistrano::Shell
- Inherits:
-
Object
- Object
- Capistrano::Shell
- Includes:
- Processable
- Defined in:
- lib/capistrano/shell.rb
Overview
The Capistrano::Shell class is the guts of the "shell" task. It implements an interactive REPL interface that users can employ to execute tasks and commands. It makes for a GREAT way to monitor systems, and perform quick maintenance on one or more machines.
Defined Under Namespace
Classes: ReadlineFallback
Instance Attribute Summary (collapse)
-
- (Object) configuration
readonly
The configuration instance employed by this shell.
Class Method Summary (collapse)
-
+ (Object) run(config)
Instantiate a new shell and begin executing it immediately.
Instance Method Summary (collapse)
-
- (Shell) initialize(config)
constructor
Instantiate a new shell.
- - (Object) read_and_execute
-
- (Object) run!
Start the shell running.
Methods included from Processable
#ensure_each_session, #process_iteration
Constructor Details
- (Shell) initialize(config)
Instantiate a new shell
33 34 35 |
# File 'lib/capistrano/shell.rb', line 33 def initialize(config) @configuration = config end |
Instance Attribute Details
- (Object) configuration (readonly)
The configuration instance employed by this shell
25 26 27 |
# File 'lib/capistrano/shell.rb', line 25 def configuration @configuration end |
Class Method Details
+ (Object) run(config)
Instantiate a new shell and begin executing it immediately.
28 29 30 |
# File 'lib/capistrano/shell.rb', line 28 def self.run(config) new(config).run! end |
Instance Method Details
- (Object) read_and_execute
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/capistrano/shell.rb', line 57 def read_and_execute command = read_line case command when "?", "help" then help when "quit", "exit" then puts "exiting" return false 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 return true end |
- (Object) run!
Start the shell running. This method will block until the shell terminates.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/capistrano/shell.rb', line 39 def run! setup puts <<-INTRO ==================================================================== Welcome to the interactive Capistrano shell! This is an experimental feature, and is liable to change in future releases. Type 'help' for a summary of how to use the shell. -------------------------------------------------------------------- INTRO loop do break if !read_and_execute end @bgthread.kill end |