<NME> rango
<BEF> #!/usr/bin/env ruby1.9
# coding: utf-8

rango_root = File.join(File.dirname(__FILE__), '..')
$:.unshift("#{rango_root}/lib")

require "rango/ext/colored_string"

def help(command, description, indentation = 40)
  indentation = indentation - command.length
  spaces = " " * indentation
  STDERR.puts(command + spaces + description)
end

case command = ARGV.first
when "create"
  require "rango/cli/generators"
  Rango::Generator.new(ARGV)
when "-i"
  require "rango"
  Rango.boot
  Rango.interactive
else
  # STDERR.puts(ColoredString.template("=== <green.bold>Usage</green.bold> ==="))
  STDERR.puts("=== Usage ===")
  help "rango create project mycoolproject", "Generate new site"
  help "rango create app mycoolapp", "Generate new application"
require "rango"

# === Helpers === #
# TODO: Generators.each { |generator| puts generator.help }
def usage
<<-HELP
=== Usage ===
rango create project mycoolproject    Generate new site
HELP
end

begin
  ARGV.shift.eql?("create") || abort(usage)
  generator_name = ARGV.shift || abort(usage)
  templater = SimpleTemplater.new(:rango)
  # This enables you to create custom generators for Rango
  load File.join(File.dirname(base), "..", "simple-templater.scope") # neccesary if we run rango locally and not from RubyGems
  templater.discover!
  generator_set = templater.find(generator_name)
  if generator_set.nil?
    abort "Generator #{generator_name} doesn't exist. Available generators are: #{templater.generators.map { |set| set.name }.inspect}"
  else
    begin
      generator_set.run(ARGV)
    rescue SimpleTemplater::TargetAlreadyExist => exception
      abort exception.message
    rescue Interrupt
      exit
    rescue Exception => exception
      abort "Exception #{exception.inspect} occured during running generator #{generator_set.inspect}\n#{exception.backtrace.join("\n")}"
    end
  end
end

<MSG> Refactored bin/rango

<DFF> @@ -1,27 +1,21 @@
 #!/usr/bin/env ruby1.9
 # coding: utf-8
 
-rango_root = File.join(File.dirname(__FILE__), '..')
-$:.unshift("#{rango_root}/lib")
-
-require "rango/ext/colored_string"
-
 def help(command, description, indentation = 40)
   indentation = indentation - command.length
   spaces = " " * indentation
   STDERR.puts(command + spaces + description)
 end
 
-case command = ARGV.first
+case command = ARGV.shift
 when "create"
-  require "rango/cli/generators"
-  Rango::Generator.new(ARGV)
+  require_relative "../lib/rango/cli/generator"
+  Rango::CLI::Generator.new(*ARGV).create
 when "-i"
   require "rango"
   Rango.boot
   Rango.interactive
 else
-  # STDERR.puts(ColoredString.template("=== <green.bold>Usage</green.bold> ==="))
   STDERR.puts("=== Usage ===")
   help "rango create project mycoolproject", "Generate new site"
   help "rango create app mycoolapp", "Generate new application"

Refactored bin/rango