Module: Foreman::Thor::Shell

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

Defined Under Namespace

Classes: Basic, Color, HTML

Constant Summary collapse

SHELL_DELEGATED_METHODS =
[:ask, :error, :set_color, :yes?, :no?, :say, :say_status, :print_in_columns, :print_table, :print_wrapped, :file_collision, :terminal_width]

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#shellObject

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



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

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

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 < Foreman::Thor
  argument :first, :type => :numeric
end

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


44
45
46
47
48
# File 'lib/foreman/vendor/thor/lib/thor/shell.rb', line 44

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

#with_paddingObject

Yields the given block with padding.



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

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