Sha256: 6ea6e8330c9cef136ca473da6a7e7ba97186024e038f0f6fdd7165e6841406fe

Contents?: true

Size: 709 Bytes

Versions: 3

Compression:

Stored size: 709 Bytes

Contents

usage 'shell'
summary 'open a shell on the Nanoc environment'
aliases 'console'
description "
Open an IRB shell on a context that contains @items, @layouts, and @config.
"

module Nanoc::CLI::Commands
  class Shell < ::Nanoc::CLI::CommandRunner
    def run
      require 'pry'

      require_site

      Nanoc::Int::Context.new(env).pry
    end

    protected

    def env
      self.class.env_for_site(site)
    end

    def self.env_for_site(site)
      {
        items: Nanoc::ItemCollectionView.new(site.items, nil),
        layouts: Nanoc::LayoutCollectionView.new(site.layouts, nil),
        config: Nanoc::ConfigView.new(site.config, nil),
      }
    end
  end
end

runner Nanoc::CLI::Commands::Shell

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
nanoc-4.1.0rc1 lib/nanoc/cli/commands/shell.rb
nanoc-4.1.0b1 lib/nanoc/cli/commands/shell.rb
nanoc-4.1.0a1 lib/nanoc/cli/commands/shell.rb