Module: Thor::Shell

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

Defined Under Namespace

Classes: Basic, Color

Constant Summary collapse

SHELL_DELEGATED_METHODS =
[:ask, :yes?, :no?, :say, :say_status, :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


40
41
42
43
44
# File 'lib/vendor/thor/lib/thor/shell.rb', line 40

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.



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

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

#shell=(shell) ⇒ Object

Sets the shell for this thor class.



53
54
55
# File 'lib/vendor/thor/lib/thor/shell.rb', line 53

def shell=(shell)
  @shell = shell
end

#with_paddingObject

Yields the given block with padding.



67
68
69
70
71
72
# File 'lib/vendor/thor/lib/thor/shell.rb', line 67

def with_padding
  shell.padding += 1
  yield
ensure
  shell.padding -= 1
end