Sha256: 9f4ad3b1898c1a351daab0d794d794653b6cf4aa9d529fdd4339829261c48e62

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

require 'parklife'
require 'thor'

module Parklife
  class CLI < Thor
    desc 'build', 'create a production build'
    option :base, desc: 'set config.base at build-time - overrides the Parkfile setting'
    def build
      # Parkfile config overrides.
      application.config.base = options[:base] if options[:base]

      application.build
    end

    desc 'routes', 'list all defined routes'
    def routes
      application.routes.each do |route|
        print route.path
        print "\tcrawl=true" if route.crawl
        puts
      end
    end

    map '--version' => :version
    desc 'version', 'output the current version of Parklife'
    def version
      puts Parklife::VERSION
    end

    private
      def application
        @application ||= Parklife.application.tap { |app|
          # Default output to stdout (can be overridden in the Parkfile).
          app.config.reporter = $stdout

          # Reach inside the consuming app's directory to apply its Parklife
          # config.
          app.load_Parkfile(File.join(Dir.pwd, 'Parkfile'))
        }
      end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
parklife-0.4.0 lib/parklife/cli.rb