Class: Padrino::Generators::Cli

### Home Classes Methods

### In Files

- lib/padrino-gen/generators/cli.rb

### Parent

Thor::Group

### Methods

- #load_boot
- #setup

### Included Modules

- Thor::Actions

### Files

- README.rdoc
- README.rdoc

### Class/Module Index

Quicksearch

- Padrino
- Padrino::Generators
- Padrino::Generators::Actions
- Padrino::Generators::Actions::ClassMethods
- Padrino::Generators::App
- Padrino::Generators::AppRootNotFound
- Padrino::Generators::Cli
- Padrino::Generators::Components
- Padrino::Generators::Components::Actions
- Padrino::Generators::Controller
- Padrino::Generators::Mailer
- Padrino::Generators::Migration
- Padrino::Generators::Model
- Padrino::Generators::Plugin
- Padrino::Generators::Project
- Padrino::Generators::Runner
- Padrino::Generators::SqlHelpers
- ActiveRecord
- ActiveRecord::Schema
- Object

No matching classes.

# Padrino::Generators::Cli

This class bootstrap `config/boot` and perform +Padrino::Generators.load_components!+ for handle 3rd party generators

### Public Instance Methods

load_boot() click to toggle source

We need to TRY to load boot because some of our app dependencies maybe have custom generators, so is necessary know who are.

@api private

    # File lib/padrino-gen/generators/cli.rb, line 21
    def load_boot
      begin
        ENV['PADRINO_LOG_LEVEL'] ||= 'test'
        ENV['BUNDLE_GEMFILE'] = File.join(options[:root], 'Gemfile') if options[:root]
        boot = options[:root] ? File.join(options[:root], 'config/boot.rb') : 'config/boot.rb'
        if File.exist?(boot)
          require File.expand_path(boot)
        else
          # If we are outside app we need to load support_lite
          require 'padrino-core/support_lite' unless defined?(SupportLite)
        end
      rescue StandardError => e
        puts "=> Problem loading #{boot}"
        puts ["=> #{e.message}", *e.backtrace].join("\n  ")
      ensure
        ENV.delete('BUNDLE_GEMFILE')
        ENV.delete('PADRINO_LOG_LEVEL')
      end
    end

setup() click to toggle source

Loads the components available for all generators. @private

    # File lib/padrino-gen/generators/cli.rb, line 43
    def setup
      Padrino::Generators.load_components!

      generator_kind  = ARGV.delete_at(0).to_s.downcase.to_sym if ARGV[0].present?
      generator_class = Padrino::Generators.mappings[generator_kind]

      if generator_class
        args = ARGV.empty? && generator_class.require_arguments? ? ['-h'] : ARGV
        generator_class.start(args)
      else
        puts "Please specify generator to use (#{Padrino::Generators.mappings.keys.join(", ")})"
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.