lib/rails_erd/cli.rb in rails-erd-1.4.7 vs lib/rails_erd/cli.rb in rails-erd-1.5.0

- old
+ new

@@ -47,10 +47,15 @@ option :only do long "--only" desc "Filter to only include listed models in diagram." end + option :only_recursion_depth do + long "--only_recursion_depth=INTEGER" + desc "Recurses into relations specified by --only upto a depth N." + end + option :exclude do long "--exclude" desc "Filter to exclude listed models in diagram." end @@ -62,10 +67,15 @@ option :prepend_primary do long "--prepend_primary=BOOLEAN" desc "Ensure primary key is at start of attribute list" end + option :cluster do + long "--cluster" + desc "Display models in subgraphs based on their namespace." + end + separator "" separator "Output options:" option :filename do long "--filename=FILENAME" @@ -147,12 +157,17 @@ private def load_application $stderr.puts "Loading application in '#{File.basename(path)}'..." - # TODO: Add support for different kinds of environment. - require "#{path}/config/environment" - Rails.application.eager_load! + begin + environment_path = "#{path}/config/environment.rb" + require environment_path + rescue ::LoadError + puts "Please create a file in '#{environment_path}' that loads your application environment." + raise + end + Rails.application.eager_load! if defined? Rails rescue TypeError end def create_diagram $stderr.puts "Generating entity-relationship diagram for #{ActiveRecord::Base.descendants.length} models..."