Sha256: 38039ce985d1abd9a547b2ada1774557611e9da9ccb61488e8ac3a32a469a3d2

Contents?: true

Size: 963 Bytes

Versions: 5

Compression:

Stored size: 963 Bytes

Contents

require File.dirname(__FILE__) + '/load_paths'

module VraptorScaffold
  class Main

    def self.execute(args)
      action = args.shift
      print_help(AppGenerator) if help? action
      run_app_generator(args.shift, args) if action == "new"
      run_scaffold_generator(args) if action == "scaffold"
    end

    def self.run_app_generator(project_path, args)
      print_help(AppGenerator) if help? project_path
      AppGenerator.new(project_path, args).invoke_all
    end

    def self.run_scaffold_generator(args)
      print_help(ScaffoldGenerator) if help? args.first
      unless File.exist?("src")
        puts "To run vraptor scaffold please go to the project root folder."
        Kernel::exit
      end
      ScaffoldGenerator.new(args).invoke_all 
    end

    def self.print_help(generator)
      generator.start(["-h"])
      Kernel::exit
    end

    def self.help?(command)
      [nil, "-h", "--help"].include?(command)
    end    
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
vraptor-scaffold-1.0.0 lib/vraptor-scaffold.rb
vraptor-scaffold-0.0.4 lib/vraptor-scaffold.rb
vraptor-scaffold-0.0.3 lib/vraptor-scaffold.rb
vraptor-scaffold-0.0.2 lib/vraptor-scaffold.rb
vraptor-scaffold-0.0.1 lib/vraptor-scaffold.rb