Sha256: d29e3720a41d11a5436a60102861efb89e6a36a983a041e01f4943a91a8dbf26

Contents?: true

Size: 995 Bytes

Versions: 11

Compression:

Stored size: 995 Bytes

Contents

require 'grape/app'
require 'thor'

module Grape::App::CLI
  class Builder < Thor::Group
    include Thor::Actions
    argument :name, required: true

    def self.source_root
      File.join(File.dirname(__FILE__), 'templates')
    end

    def copy_templates
      prefix = File.join(self.class.source_root, '')

      Dir[File.join(self.class.source_root, '**', '*')].each do |file|
        next if File.directory?(file)

        file.sub! prefix, ''
        copy_file file, File.join(name, file)
      end
    end

    def init_lib
      empty_directory File.join(name, 'lib', name)
    end

  end

  class Runner < Thor
    register Builder, :new, 'new NAME', 'create a new application'

    desc 'console ENV', 'Launch console'
    def console(env='development')
      ENV['GRAPE_ENV'] = env
      require File.expand_path('config/environment', Dir.pwd)

      require 'irb'
      require 'irb/completion'

      ARGV.clear
      IRB.start
    end
  end
end

Grape::App::CLI::Runner.start

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
grape-app-0.8.4 lib/grape/app/cli.rb
grape-app-0.8.3 lib/grape/app/cli.rb
grape-app-0.8.2 lib/grape/app/cli.rb
grape-app-0.8.1 lib/grape/app/cli.rb
grape-app-0.8.0 lib/grape/app/cli.rb
grape-app-0.7.1 lib/grape/app/cli.rb
grape-app-0.6.4 lib/grape/app/cli.rb
grape-app-0.6.3 lib/grape/app/cli.rb
grape-app-0.6.2 lib/grape/app/cli.rb
grape-app-0.6.1 lib/grape/app/cli.rb
grape-app-0.6.0 lib/grape/app/cli.rb