<NME> rango
<BEF> #!/usr/bin/env ruby
# encoding: utf-8

if RUBY_VERSION < "1.9.1"
  abort "Rango requires at least Ruby 1.9.1. If you run JRuby, please ensure you used the --1.9 switch for JRuby command, for example jruby --1.9 -S rango create project blog"
end

base   = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
libdir = File.expand_path(File.join(File.dirname(base), "..", "lib"))

# because of system installation, there is bin/../lib, but not bin/../lib/rango
if File.directory?(File.join(libdir, "rango"))
  $:.unshift(libdir) unless $:.include?(libdir)
end

begin
  require "simple-templater"
rescue LoadError
  abort "You have to install simple-templater first!"
end
end

# === Helpers === #
def usage
  # TODO: Generators.each { |generator| puts generator.help }
  STDERR.puts("=== Usage ===")
  help "rango create project mycoolproject", "Generate new site"
  help "rango create app mycoolapp", "Generate new application"
  help "rango -i", "Start Rango console"
end

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

case command = ARGV.shift
  ARGV.shift.eql?("create") || abort(usage)
  generator_name = ARGV.shift || abort(usage)
  templater = SimpleTemplater.new(:rango)
  require "rango/cli/generator"
  begin
    Rango::CLI::Generator.new(*ARGV).create
  rescue ArgumentError
    abort usage
  end
when "-i"
  require "rango"
      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> Improved bin/rango, so it warns about exceptions + refactoring

<DFF> @@ -21,18 +21,13 @@ if File.directory?(File.join(libdir, "rango"))
 end
 
 # === Helpers === #
+# TODO: Generators.each { |generator| puts generator.help }
 def usage
-  # TODO: Generators.each { |generator| puts generator.help }
-  STDERR.puts("=== Usage ===")
-  help "rango create project mycoolproject", "Generate new site"
-  help "rango create app mycoolapp", "Generate new application"
-  help "rango -i", "Start Rango console"
-end
-
-def help(command, description, indentation = 40)
-  indentation = indentation - command.length
-  spaces = " " * indentation
-  STDERR.puts(command + spaces + description)
+<<-HELP
+=== Usage ===
+rango create project mycoolproject    Generate new site
+rango create app mycoolapp            Generate new application
+HELP
 end
 
 case command = ARGV.shift
@@ -42,8 +37,8 @@ when "create"
   require "rango/cli/generator"
   begin
     Rango::CLI::Generator.new(*ARGV).create
-  rescue ArgumentError
-    abort usage
+  rescue ArgumentError => exception
+    abort [exception.inspect, "", usage].join("\n")
   end
 when "-i"
   require "rango"

Improved bin/rango, so it warns about exceptions + refactoring