<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!"
  $:.unshift(libdir) unless $:.include?(libdir)
end

def help(command, description, indentation = 40)
  indentation = indentation - command.length
  spaces = " " * indentation
  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!
  # we can't use require_relative because it can be symlinked to
  # /usr/bin or just be located in different place than we expect
  require "rango/cli/generator"
  Rango::CLI::Generator.new(*ARGV).create
when "-i"
  require "rango"
  Rango.boot
  Rango.interactive
else
  # 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"
  exit 1
end

<MSG> Give usage message if generator raise argument error

<DFF> @@ -20,6 +20,15 @@ if File.directory?(File.join(libdir, "rango"))
   $:.unshift(libdir) unless $:.include?(libdir)
 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
@@ -31,16 +40,15 @@ when "create"
   # we can't use require_relative because it can be symlinked to
   # /usr/bin or just be located in different place than we expect
   require "rango/cli/generator"
-  Rango::CLI::Generator.new(*ARGV).create
+  begin
+    Rango::CLI::Generator.new(*ARGV).create
+  rescue ArgumentError
+    abort usage
+  end
 when "-i"
   require "rango"
   Rango.boot
   Rango.interactive
 else
-  # 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"
-  exit 1
+  abort usage
 end

Give usage message if generator raise argument error