Sha256: c1e767b0ef50b9471a0145de5e1c606563f2731e7ba03908f2de508cc662b15a

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

# CLI Module
module Middleman::Cli
  # The CLI Config class
  class Config < Thor::Group
    include Thor::Actions

    check_unknown_options!

    class_option :environment,
                 aliases: '-e',
                 default: ENV['MM_ENV'] || ENV['RACK_ENV'] || 'development',
                 desc: 'The environment Middleman will run under'
    def console
      require 'json'
      require 'middleman-core'
      require 'middleman-core/logger'

      opts = {
        environment: options['environment']
      }

      # Don't output info messages
      ::Middleman::Logger.singleton(2, false)

      app = ::Middleman::Application.new do
        config[:disable_sitemap] = true
        config[:watcher_disable] = true
        config[:exit_before_ready] = true
        config[:environment] = opts[:environment].to_sym if opts[:environment]
      end

      puts JSON.pretty_generate(app.config.to_h)

      app.shutdown!
    end

    # Add to CLI
    Base.register(self, 'config', 'config [options]', 'Output a Middleman configuration in JSON format')
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
middleman-cli-4.1.3 lib/middleman-cli/config.rb