Sha256: 8e6c8623f5f5f5e057a15d216a1efd48440261d5aac3babd7aaf67d67acfbebf

Contents?: true

Size: 1.78 KB

Versions: 5

Compression:

Stored size: 1.78 KB

Contents

require 'thor'
require 'gris/generators'
require 'gris/version'

Gris.load_environment if defined?(Dotenv)

module Gris
  class CLI
    class Generate < Thor
      register(
        Generators::ApiGenerator,
        'api',
        'api <api_name>',
        'Generate a Grape API, Model and Presenter'
      )

      register(
        Generators::MigrationGenerator,
        'migration',
        'migration <migration_name> [field[:type][:index] field[:type][:index]]',
        'Generate a Database Migration'
      )
    end
  end
  class CLI
    class Base < Thor
      desc 'version', 'Returns the Gris version number'
      def version
        say Gris::VERSION
      end

      desc 'console [environment]', 'Start the Gris console'
      options aliases: 'c'
      def console(environment = nil)
        ENV['RACK_ENV'] = environment || 'development'

        require 'racksh/init'

        begin
          require 'pry'
          interpreter = Pry
        rescue LoadError
          require 'irb'
          require 'irb/completion'
          interpreter = IRB
          # IRB uses ARGV and does not expect these arguments.
          ARGV.delete('console')
          ARGV.delete(environment) if environment
        end

        Rack::Shell.init

        $0 = "#{$PROGRAM_NAME} console"
        interpreter.start
      end

      register(
        Generators::ScaffoldGenerator,
        'new',
        'new <app_name> [app_path]',
        'Generates a scaffold for a new Gris service'
      )

      desc 'generate api <api_name>', 'Create a Grape API, Model and Representer'
      subcommand 'generate api', Gris::CLI::Generate

      desc 'generate migration <migration_name> [field[:type][:index] field[:type][:index]]', 'Create a Database Migration'
      subcommand 'generate', Gris::CLI::Generate
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gris-0.2.4 lib/gris/cli.rb
gris-0.2.3 lib/gris/cli.rb
gris-0.2.2 lib/gris/cli.rb
gris-0.2.1 lib/gris/cli.rb
gris-0.2.0 lib/gris/cli.rb