Class: Middleman::Cli::Console

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
middleman-cli/lib/middleman-cli/console.rb

Overview

The CLI Console class

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.interact_with(context)

This method returns an undefined value.

Start an interactive console in the context of the provided object.



38
39
40
41
42
43
# File 'middleman-cli/lib/middleman-cli/console.rb', line 38

def self.interact_with(context)
  IRB.setup nil
  IRB.conf[:MAIN_CONTEXT] = IRB::Irb.new.context
  require 'irb/ext/multi-irb'
  IRB.irb nil, context
end

Instance Method Details

#consoleObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'middleman-cli/lib/middleman-cli/console.rb', line 17

def console
  require 'middleman-core'
  require 'irb'

  opts = {
    environment: options['environment'],
    debug: options['verbose']
  }

  @app = ::Middleman::Application.new do
    config[:environment] = opts[:environment].to_sym if opts[:environment]

    ::Middleman::Logger.singleton(opts[:debug] ? 0 : 1, opts[:instrumenting] || false)
  end

  self.class.interact_with @app
end