Sha256: 35639b4588b5673cd2e3d71349e3cdf585e13a127425c0fd665c6765d8851b8d

Contents?: true

Size: 1.18 KB

Versions: 16

Compression:

Stored size: 1.18 KB

Contents

# CLI Module
module Middleman::Cli

  # A thor task for creating new projects
  class Console < Thor
    include Thor::Actions

    check_unknown_options!

    namespace :console
    
    desc "console [options]", "Start an interactive console in the context of your Middleman application"
    method_option :environment,
      :aliases => "-e",
      :default => ENV['MM_ENV'] || ENV['RACK_ENV'] || 'development',
      :desc    => "The environment Middleman will run under"
    method_option :verbose,
      :type    => :boolean,
      :default => false,
      :desc    => 'Print debug messages'
    def console
      require "middleman-core"
      require "irb"

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

      @app =::Middleman::Application.server.inst do
        if opts[:environment]
          set :environment, opts[:environment].to_sym
        end

        logger(opts[:debug] ? 0 : 1, opts[:instrumenting] || false)
      end

      # TODO: get file watcher / reload! working in console

      IRB.setup nil
      IRB.conf[:MAIN_CONTEXT] = IRB::Irb.new.context
      require 'irb/ext/multi-irb'
      IRB.irb nil, @app
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
middleman-core-3.2.1 lib/middleman-core/cli/console.rb
middleman-core-3.2.0 lib/middleman-core/cli/console.rb
middleman-core-3.1.6 lib/middleman-core/cli/console.rb
middleman-core-3.1.5 lib/middleman-core/cli/console.rb
middleman-core-3.1.4 lib/middleman-core/cli/console.rb
middleman-core-3.1.3 lib/middleman-core/cli/console.rb
middleman-core-3.1.2 lib/middleman-core/cli/console.rb
middleman-core-3.1.1 lib/middleman-core/cli/console.rb
middleman-core-3.1.0 lib/middleman-core/cli/console.rb
middleman-core-3.1.0.rc.4 lib/middleman-core/cli/console.rb
middleman-core-3.1.0.rc.3 lib/middleman-core/cli/console.rb
middleman-core-3.1.0.rc.2 lib/middleman-core/cli/console.rb
middleman-core-3.1.0.rc.1 lib/middleman-core/cli/console.rb
middleman-core-3.1.0.beta.3 lib/middleman-core/cli/console.rb
middleman-core-3.1.0.beta.2 lib/middleman-core/cli/console.rb
middleman-core-3.1.0.beta.1 lib/middleman-core/cli/console.rb