Module: Thor::Shell

Defined in:
lib/thor/shell.rb,
lib/thor/shell/basic.rb,
lib/thor/shell/color.rb

Defined Under Namespace

Classes: Basic, Color

Constant Summary collapse

SHELL_DELEGATED_METHODS =
[:ask, :yes?, :no?, :say, :say_status, :print_list, :print_table]

Instance Method Summary collapse

Instance Method Details

#initialize(args = [], options = {}, config = {}) ⇒ Object

Add shell to initialize config values.

Configuration

shell<Object>

An instance of the shell to be used.

Examples

class MyScript < Thor
  argument :first, :type => :numeric
end

MyScript.new [1.0], { :foo => :bar }, :shell => Thor::Shell::Basic.new


34
35
36
37
38
# File 'lib/thor/shell.rb', line 34

def initialize(args=[], options={}, config={})
  super
  self.shell = config[:shell]
  self.shell.base ||= self if self.shell.respond_to?(:base)
end

#shellObject

Holds the shell for the given Thor instance. If no shell is given, it gets a default shell from Thor::Base.shell.



43
44
45
# File 'lib/thor/shell.rb', line 43

def shell
  @shell ||= Thor::Base.shell.new
end

#shell=(shell) ⇒ Object

Sets the shell for this thor class.



49
50
51
# File 'lib/thor/shell.rb', line 49

def shell=(shell)
  @shell = shell
end